When it comes to apply, we all know that change this point, also will immediately and call together, MDN official online also said:
In fact, when we use call and apply, we all think of their function of changing this function,
As the MDN says, there is only one difference between apply and call: The two parameters of the Apply method accept the parameter array!
In other words: The second "parameter array" of apply will eventually be called by the function called apply;
So we can also take advantage of this feature to do an array of scattered operations, as described in MDN:
Of course we can also use ES6 's expansion statement, as follows:
The reason to write this article is to warn yourself: think not too limited , as if you feel that apply can only be used to change the point of this function. When we look at Math.max. Apply(null, arr) This kind of circle, in fact, this is omitted to expand the operation of the array.
When you find doubt, you can empty your knowledge of the past and re-read the API. Think again about the problem.
Just like you do physics problems, in the mind never remember questions, the brain only need to remember the formula and principle, all the topics are to think analysis and answer, Status quo!! Instead of classifying the topic, we can recall the problem solving method of the modified type.
The use of the "non-change this" for apply