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
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):
- But in actual use, the parameters are often not fixed, and the realization of not fixed parameters:
- 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
- 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
- Realization of fixed parameters (use closures directly, and multiple parameters can be written infinitely below function):
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
How does Asyc Await perform error interception?
- try/catch
asynchronous development process?
- Callback (event callback/AJAX) (callback hell)
- Promise (commonly used)
- Generator/yield (difficult to understand)
- Async/Await
is the usage scenario and implementation principle of $nextTick in 1610c9a7f5fdfa VUE?
- A callback executed after the dom update is complete
- Implementation principle: TODO
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
- implements a simple two-way binding (just use defineProperty)
- Anti-shake/throttle (I wrote this out! But because it is a high frequency problem, please also record it~)
...To be continued
... please correct me
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。