Home > Article > Web Front-end > Detailed analysis of the use of apply method in js_javascript skills
1. The general approach to object inheritance is to copy: Object.extend
The implementation of prototype.js is:
The apply method can hijack the method of another object and inherit the properties of another object
Function.apply(obj, args) method can receive two parameters
obj: This object will replace this object in the Function class
args: This is an array, which will be passed as parameters to Function (args-->arguments)
apply demonstration code is as follows: