js face questions summary

JavaScript interview summary

  • What is the difference between call and apply that which is better performance?

Are used to change this point fn.call (obj, 10,20,30); - > a is a value passed
apply (obj, [1,2,3,4,5,] ) -> is the method is passed to the array
bind -> it does not perform the function, but the function of the pre-treatment
method call function with the prototype are the following apply, and each function as a function of the prototype the following example, can be adjusted so that methods of the following function prototype, call point with change are used to apply this is

Derived to test -> to achieve their own performance tests (multiple tests take the middle value, with relevant external factors)
time code execution can test period
- use is -console.time ( "name")
code to execute put the middle
- console .timeEnd ( "name")

performance? -----> before three parameters are passed call now apply the same argument to the function of more than three words better performance -call point (ps: expert answers, there is no verified) (jQuery source code inside annotated call the performance is better than apply) -> derived source to Have ago jQuery

  • Interview Skills answer: Answer to the first aspect of the class with instances - the introduction of derivatives

Learn new features ES6 - - destruction expand operator (one to each of the array expand out) - Function arrow -
Here Insert Picture Description

  • Implement (5) .add (3) .minus (2), so that the output result is: 6
Published 25 original articles · won praise 13 · views 3218

Guess you like

Origin blog.csdn.net/weixin_42216818/article/details/103425034