JavaScript Function - apply()
Last Updated : 17 Mar 2025
The JavaScript Function apply() method is used to call a function contains this value and an argument contains elements of an array. Unlike call() method, it contains the single array of arguments.
Syntax
Parameter
thisArg - It is optional. The this value is given for the call to a function.
array - It is optional. It is an array-like object.
Return Value
It returns the result of the calling function along provided this value and arguments.
JavaScript Function apply() method Example
Example 1
Let's see an example to determine the maximum element.
Output:
Example 2
Let's see an example to determine the minimum element.
Output:
Example 3
Let's see an example to join arrays of same type.
Output:
Example 4
Let's see an example to join array of different type.
Output:
1,2,3,4,One,Two,Three,Four