Learn JavaScript
call, apply and bind
26.2
Lesson

apply()

apply() also allows a function or method to be declared in an object and executed by another object. But apply() accepts the arguments in the form of an array.

In the example given below, when we use apply() with firstPerson, the value of this.name is Sam. The value of this.name changes to Oliver when we use the apply() method with secondPerson. ​