Favorites

JavaScript Function.prototype.apply() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Function.prototype.apply()
JavaScript Function Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The apply() method calls a function with a given this value and its arguments supplied as an array.

Description

The apply() method calls the function with a chosen this value and the arguments provided as an array. It's the same as call() except for how arguments are passed. Spread syntax has replaced most uses: Math.max.apply(null, nums) can be written Math.max(...nums).

Passing null or undefined as thisArg is common when the function doesn't use this; in non-strict code, this then becomes the global object. The arguments can be any array-like object, such as arguments or a NodeList.

Reflect.apply(fn, thisArg, args) does the same thing and is often used in Proxy handlers. Arrow functions ignore the thisArg, since they don't have their own this.

Syntax

func.apply(thisArg)
func.apply(thisArg, argsArray)

Parameters

  • thisArgThe value to use as this inside the function.
  • argsArrayOptional. An array (or array-like object) of arguments.

Return Value

The result of calling the function.

Example

function greet(greeting, punct) {
  return greeting + ', ' + this.name + punct;
}
console.log(greet.apply({ name: 'Sam' }, ['Hi', '!']));
console.log(Math.max.apply(null, [3, 9, 4]));

Browser Support

The following information will show you the current browser support for the Function.prototype.apply() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee