国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Function() function object in JS
歐陽克
歐陽克 2017-06-12 09:29:33
0
3
945

The Object() constructor can be seen as: var Object=new Function();
The Array() constructor can be seen as: var Array=new Function();
.... Then:
Function() constructor can be seen as: var Function=new Function()?
Created itself?
There are other similar native objects, Object.prototype, as the ultimate prototype object of the prototype chain, how was it created? Is it also created by new Object()? But shouldn’t Object.prototype be the first object in the JS native system?
I feel like I can no longer understand the prototype-based thinking of JS. Please give me some guidance...

歐陽克
歐陽克

溫故而知新,可以為師矣。 博客:www.ouyangke.com

reply all(3)
學(xué)習ing

In fact, it is not a chicken-and-egg problem. All objects are actually functions, including the function itself. Let’s talk about the prototype first. The prototype is based on the constructor and __proto__, and these two are included in the prototype, and these three are composed together. A function is created; the prototype chain is based on the direction of __proto__. The prototype chain is bottom-up and based on the principle of proximity. It searches for the desired attributes and forms a prototype chain; so js is a simulated language, which is also the essential difference between it and other languages!

我想大聲告訴你
  1. There is a difference between objects (functions) that can be generated through new and all objects (functions) that need to be generated through new.

  2. Function, Object, etc. can be considered to be provided in the process of js implementation. My understanding is that in order to implement the prototype chain, the browser adds __proto__-->* when providing these functions according to the implementation of the prototype chain. **.prototype. It means that the js environment provides several special objects (functions), and then these objects (functions) are processed in order not to violate the specifications.

The first one is definitely correct, the second one is my understanding.

伊謝爾倫
                      null
                       |
           Object---prototype
              |
Function---prototype
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template