Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

apply

I wonder if it is OK to call function.apply with a null first argument. (The use case I have in mind is to pass an array of arguments to a 'regular' function).

For example:


function f(a, b, c) { 
 ...
} 

function call_some(fun, arg1, arg2, arg3, ...) { 
  var args = arguments.splice(1,1);
  return fun.apply(null, args); // ....
} 
...
call_some(f, 11, 2, true);
That's entirely fine; I edited the page to better describe how the first argument's used. --Waldo 21:27, 19 October 2007 (PDT)

Document Tags and Contributors

 Contributors to this page: Waldo, Rsivan
 Last updated by: Waldo,