15.3.4.4 Function.prototype.call(thisArg[, arg1[, arg2[, ...]]])

2010-07-04

mixed Function.prototype.call(thisArg[, arg1[, arg2[, ...]]]) throws TypeError

Like apply, call allows you to execute a function in a different context. The only difference between call and apply is that for call, each parameter to call is passed on to the function. In apply, only the second parameter (assumed to be an array) is mapped on the parameter list.

Function.prototype.call.length = 1

Note that the this value (first argument) is passed on unchanged. In ES3 it would be global if undefined or null and otherwise fed through ToObject. So you can pass on any value as the this for a function now.

Code: (Meta Ecma)
Function.prototype.call = function(){
if (!IsCallable(this)) throw TypeError;
var argList = Array.prototype.slice.call(arguments);
var thisArg = argList.shift();
this.[[Call]](thisArg, argList);
}