call() runs a function right now and lets you choose what this means inside it. You pass the value for this first, then the normal arguments one by one, separated by commas.
It returns whatever the function returns. You will use it to run one function for different objects, or to borrow a method from another object that does not have it.
Remember
func.call(thisArg, arg1, arg2, ...);
thisArg → what "this" is inside func
arg1... → the arguments, one by one
returns → whatever func returns
call() runs the function immediately.
Syntax
Call call() on any function. The first argument is the value for this; everything after it is passed to the function.
Optional. The value that this has inside the function. In strict mode it is used exactly as you pass it. In normal (non-strict) code, null and undefined are replaced by the global object, and text or numbers are wrapped in an object. An arrow function ignores it.
arg1, arg2, ..., argN
Optional. The arguments for the function, given one by one in the same order as the function's own parameters.
Return Value
Return Value
Description
The function's result
Whatever the function returns is returned by call().
undefined
The function has no return statement.
An error from the function
If the function throws, the error passes through call() unchanged.
JavaScript Examples
Example 1 — Run One Function for Different Objects
The introduce() function reads this.name. With call() the same function can speak for two different people.
JavaScript
function introduce(greeting, punctuation) {
return greeting + ", I am " + this.name + punctuation;
}
const alice = { name: "Alice" };
const bob = { name: "Bob" };
console.log(introduce.call(alice, "Hello", "!"));
console.log(introduce.call(bob, "Hi", "."));
console.log(typeof introduce.call(alice, "Hey", "?"));
One function.introduce() uses this.name, so its result depends on what this is.
Pick this and pass arguments.introduce.call(alice, "Hello", "!") sets this to alice, then passes "Hello" and "!" as the two parameters. The second call does the same for bob.
It returns the result.call() gives back what the function returned, so typeof reports "string".
Example 2 — Borrow an Array Method for an Array-Like Object
The object below looks like an array (numbered keys and a length), but it is not one. call() lets it use array methods anyway.
Is it an array? false
Has map? undefined
A-B-C
a+b+c
How It Works
Not a real array.letters has no map() method of its own, so letters.map(...) would fail.
Borrow the method.Array.prototype.map.call(letters, ...) runs the array's map() with this set to letters. It reads the numbered keys and the length, so it works.
Use it again. The same trick works for join(). The results are normal arrays and text, even though the source object was not an array.
Example 3 — See That Arrow Functions Ignore call()
A regular function follows the this you give it. An arrow function keeps the this from the place where it was created.
Regular function.teamA.regular() uses teamA as this. With call(teamB), the same function now sees teamB.
Arrow function.makeArrow() returns an arrow function. It was created while this was teamA, so it remembers teamA.
call() has no effect on it. Both arrow() and arrow.call(teamB) print "Team A". That is why you should not use arrow functions for methods that rely on call().
Compatibility
Browser & Runtime Support
call() is one of the oldest JavaScript features. Every browser and every Node.js version supports it.
✓ ES3 · Works everywhere
func.call()
Supported in all browsers, including old ones, and in Node.js, Deno and Bun.
ES3Standard since
Google ChromeAll versions · Desktop & Mobile
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
OperaAll versions
Full support
Samsung InternetAll versions · Android
Full support
Android WebViewAll versions
Full support
Node.jsAll versions · Server runtime
Supported
DenoAll versions · JavaScript runtime
Supported
BunAll versions · JavaScript runtime
Supported
Internet ExplorerAll versions
Full support
func.call()Excellent
Bottom line: You can use call() anywhere. The only thing that changes between old and new code is the strict-mode rule for null and undefined as thisArg.
Frequently Asked Questions
It runs a function immediately, with the value you choose as this and with the arguments you list after it. It returns whatever the function returns. It is a method of every function, so you write it as myFunction.call(thisValue, arg1, arg2).
They do the same job. The only difference is how you pass the arguments: call() takes them one by one (fn.call(obj, 1, 2, 3)), while apply() takes them in one array (fn.apply(obj, [1, 2, 3])).
Pass null (or undefined). The function never reads this, so it does not matter. Math.max.call(null, 4, 9, 2) is a common example. In older non-strict code, null becomes the global object, which is harmless here.
An arrow function does not have its own this. It uses the this of the place where it was written. call(), apply() and bind() can pass arguments to an arrow function, but they cannot change its this.
call() runs the function now. bind() does not run it; it returns a new function with this already fixed, which you can call later, for example as an event handler or timer callback.