JavaScript apply() Function
JavaScript apply() Function
The apply()
function calls a function or method as if it belonged to thisObj and passes an array of arguments to the function or method.
Note: The call()
function passes the arguments individually. Whereas, the apply()
function passes an array of arguments.
Basic Example
The following is the basic example to be understood before proceeding with a apply()
function.
Example
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
Object | Optional | The value of thisObj provided for the call to a function. |
argsArray | Optional | Array of arguments for the function. |
apply() with Object and without Arguments
Example
apply() with Object and Arguments
Note: An array of arguments is passed instead of individual arguments.
Example
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.