search

Home  >  Q&A  >  body text

Function() function object in JS

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...

欧阳克欧阳克2725 days ago804

reply all(3)I'll reply

  • 学习ing

    学习ing2017-06-12 09:31:33

    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!

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-12 09:31:33

    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.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-12 09:31:33

                          null
                           |
               Object---prototype
                  |
    Function---prototype
    

    reply
    0
  • Cancelreply