Guest User

Untitled

a guest
Jan 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. const x = ['p0', 'p1', 'p2'];
  2. call_me(x[0], x[1], x[2]); // I don't like it
  3.  
  4. function call_me (param0, param1, param2 ) {
  5. // ...
  6. }
  7.  
  8. const args = ['p0', 'p1', 'p2'];
  9. call_me.apply(this, args);
  10.  
  11. call_me(...args);
  12.  
  13. var x = [ 'p0', 'p1', 'p2' ];
  14. call_me(x);
  15.  
  16. function call_me(params) {
  17. for (i=0; i<params.length; i++) {
  18. alert(params[i])
  19. }
  20. }
  21.  
  22. var x = ['p0', 'p1', 'p2'];
  23. call_me.apply(null, x);
  24.  
  25. call_me(...x)
  26.  
  27. var x = [ 'p0', 'p1', 'p2' ];
  28. call_me.apply(this, x);
  29.  
  30. function call_me () {
  31. // arguments is a array consisting of params.
  32. // arguments[0] == 'p0',
  33. // arguments[1] == 'p1',
  34. // arguments[2] == 'p2'
  35. }
  36.  
  37. function FollowMouse() {
  38. for(var i=0; i< arguments.length; i++) {
  39. arguments[i].style.top = event.clientY+"px";
  40. arguments[i].style.left = event.clientX+"px";
  41. }
  42.  
  43. };
  44.  
  45. <body onmousemove="FollowMouse(d1,d2,d3)">
  46.  
  47. <p><div id="d1" style="position: absolute;">Follow1</div></p>
  48. <div id="d2" style="position: absolute;"><p>Follow2</p></div>
  49. <div id="d3" style="position: absolute;"><p>Follow3</p></div>
  50.  
  51.  
  52. </body>
  53.  
  54. <body onmousemove="FollowMouse(d1,d2)">
  55.  
  56. <body onmousemove="FollowMouse(d1)">
  57.  
  58. function hash() {
  59. return arguments[0]+','+arguments[1];
  60. }
  61.  
  62. hash(1,2); // "1,2" whoaa
  63.  
  64. function hash() {
  65. return arguments.join();
  66. }
  67.  
  68. hash(1,2,4,..); // Error: arguments.join is not a function
  69.  
  70. function hash() {
  71. return [].join.call(arguments);
  72. }
  73.  
  74. hash(1,2,3,4); // "1,2,3,4" whoaa
  75.  
  76. Let glue be the first argument or, if no arguments, then a comma ",".
  77. Let result be an empty string.
  78. Append this[0] to result.
  79. Append glue and this[1].
  80. Append glue and this[2].
  81. …Do so until this.length items are glued.
  82. Return result.
  83.  
  84. var fruits = ["Banana", "Orange", "Apple", "Mango"];
  85. function myFunction(name)
  86. {
  87. var nameArray = name.split(',');
  88. .
  89. .
  90. .
  91. }
  92.  
  93. myFunction(fruits.join(','));
  94.  
  95. myFunction("orange,Apple,fruits");
Add Comment
Please, Sign In to add comment