头图
After being abused by an interview, I found that I didn’t know enough about some issues, or I knew how to use it, but I couldn’t say it. I clearly couldn’t explain the ideas/processes of the project I wrote, and there was inheritance that I just gave up to understand before. /Deep into the principles and so on, I will try my best to organize and record them when I think about it in the future
  1. are some practical scenarios in 1610c9a7f5fa9e work that can use closures?

    • closure : a function and its surrounding state (lexical environment, lexical environment) reference is bundled together-from MDN (lexical environment: according to the location of this variable to determine where it can be used)
    • solved by 1610c9a7f5fafc/purpose of use : Use function external data inside the function to solve the problem that js does not have private variables
    • Return to the topic : Closures can be used wherever private variables are needed. For example, the implementation of the anti-shake throttling function uses closures, as well as the development of plug-ins, etc., and the application scenarios are very wide.
    • Thinking Expansion : When I looked at the function currying before, I was in a state of a little understanding, so I will reorganize it here.

      • Realization of fixed parameters (use closures directly, and multiple parameters can be written infinitely below function):
        image.png
      • But in actual use, the parameters are often not fixed, and the realization of not fixed parameters:
        image.png
      • You have to call an empty one, which seems a bit strange (I saw that other people’s implementations used toString before, but I’m not sure why toString can determine whether to return the result? So I tried it myself, and toString really doesn’t work unless you manually give the function to the function. Wrap a layer of String..., you can try here
        image.png
      • Ah, the first question has been written for a long time. When I checked the information, I saw the animations of other people’s blogs. It was so interesting... Then... I ran off the track... ORZ
  2. The difference between Axios and Ajax?

    • Ajax is a package based on XHR and relies on JQuery
    • Axios is also based on XHR packaging, but it is implemented using Promise
    • Axios is more convenient and does not depend on any framework
  3. How does Asyc Await perform error interception?

    • try/catch
  4. asynchronous development process?

    • Callback (event callback/AJAX) (callback hell)
    • Promise (commonly used)
    • Generator/yield (difficult to understand)
    • Async/Await
  5. is the usage scenario and implementation principle of $nextTick in 1610c9a7f5fdfa VUE?

    • A callback executed after the dom update is complete
    • Implementation principle: TODO
  6. inheritance and prototype chain

    • The difference between prototype and __proto__

      • __proto__ points to prototype
      • After each object is created, there will be a __proto__
      • prototype is a built-in property of the function
      • __proto__ is a built-in property of the object
    • All js objects are instances of Object, inheriting the properties and methods of Object.prototype
    • Implement an inheritance // TODO
  7. implements a simple two-way binding (just use defineProperty)
    image.png
  8. Anti-shake/throttle (I wrote this out! But because it is a high frequency problem, please also record it~)
    image.png

...To be continued

... please correct me


himushroom
1.5k 声望169 粉丝

溪水慢慢流淌