Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const x = ['p0', 'p1', 'p2'];
- call_me(x[0], x[1], x[2]); // I don't like it
- function call_me (param0, param1, param2 ) {
- // ...
- }
- const args = ['p0', 'p1', 'p2'];
- call_me.apply(this, args);
- call_me(...args);
- var x = [ 'p0', 'p1', 'p2' ];
- call_me(x);
- function call_me(params) {
- for (i=0; i<params.length; i++) {
- alert(params[i])
- }
- }
- var x = ['p0', 'p1', 'p2'];
- call_me.apply(null, x);
- call_me(...x)
- var x = [ 'p0', 'p1', 'p2' ];
- call_me.apply(this, x);
- function call_me () {
- // arguments is a array consisting of params.
- // arguments[0] == 'p0',
- // arguments[1] == 'p1',
- // arguments[2] == 'p2'
- }
- function FollowMouse() {
- for(var i=0; i< arguments.length; i++) {
- arguments[i].style.top = event.clientY+"px";
- arguments[i].style.left = event.clientX+"px";
- }
- };
- <body onmousemove="FollowMouse(d1,d2,d3)">
- <p><div id="d1" style="position: absolute;">Follow1</div></p>
- <div id="d2" style="position: absolute;"><p>Follow2</p></div>
- <div id="d3" style="position: absolute;"><p>Follow3</p></div>
- </body>
- <body onmousemove="FollowMouse(d1,d2)">
- <body onmousemove="FollowMouse(d1)">
- function hash() {
- return arguments[0]+','+arguments[1];
- }
- hash(1,2); // "1,2" whoaa
- function hash() {
- return arguments.join();
- }
- hash(1,2,4,..); // Error: arguments.join is not a function
- function hash() {
- return [].join.call(arguments);
- }
- hash(1,2,3,4); // "1,2,3,4" whoaa
- Let glue be the first argument or, if no arguments, then a comma ",".
- Let result be an empty string.
- Append this[0] to result.
- Append glue and this[1].
- Append glue and this[2].
- …Do so until this.length items are glued.
- Return result.
- var fruits = ["Banana", "Orange", "Apple", "Mango"];
- function myFunction(name)
- {
- var nameArray = name.split(',');
- .
- .
- .
- }
- myFunction(fruits.join(','));
- myFunction("orange,Apple,fruits");
Add Comment
Please, Sign In to add comment