JavaScript Function.prototype.call() Method
The call() method calls a function with a given this value and arguments listed one by one.
Description
The call() method calls the function immediately with a chosen this value and arguments listed individually. It's used to borrow methods from other objects, such as Array.prototype.slice.call(arguments), although modern alternatives like Array.from() usually exist.
Passing null or undefined as thisArg is fine when the function doesn't use this. call() and apply() run the function straight away, whereas bind() returns a new function for later.
A classic use is calling a parent constructor from a child constructor in pre-class code, Parent.call(this, name); with classes, super(name) does that job. Arrow functions ignore the thisArg argument.
Syntax
func.call(thisArg)
func.call(thisArg, arg1, arg2, ...)Parameters
- thisArgThe value to use as
thisinside the function. - arg1, arg2, ...Optional. Arguments for the function.
Return Value
The result of calling the function.
Example
Browser Support
The following information will show you the current browser support for the Function.prototype.call() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





