Each function contains two properties: length and prototype
Length: The number of named parameters that the current function hopes to accept
Prototype: It is the real place to save all their strength methods
Each function contains two non-inherited methods: apply() and call()
These two methods call functions in a specific scope, which is actually equivalent to setting the value of this object in the function body
First, apply() accepts two parameters: one is the scope in which the function runs, and the other is the parameter array (which can be an array instance or an arguments object)
Secondly, the first parameter of the call method has not changed. What has changed is that the remaining parameters are all passed parameters. The parameters passed to the function need to be listed one by one
As to which method is more convenient to use, it all depends on your wishes. If there are no parameters, it will be the same regardless of which one is used.
However, the apply and call methods are definitely not just for how to get the hull parameters.
Their real use of martial arts is to expand the function of the function.
The biggest advantage of using apply and call to expand the scope is that it does not require any coupling relationship with the method.
ECMAScript5 also defines a method: bind(). This method will create an instance of the function whose this value will be bound to the value passed to the bind function
The above is the entire content of this article, I hope you guys will like it.