<! DOCTYPE HTML> <HTML> <head> <Meta charset = "UTF-. 8"> <title> </ title> </ head> <body> </ body> <Script type = "text / JavaScript"> section a 1, a general object function and function objects Object var obj = {}; var obj = new new Object (); obj.constructor === Object obj .__ proto__ === Object.prototype instance constructor equal __proto__ Object.prototype prototype object 2, constructors // each object has a constructor property, it can be obtained constructor. // constructor Constructor Constructor // instance attribute (constructor) pointing constructor. * 3, the prototype object // Each object has __proto__ property, but only have a prototype property of function objects // prototype object, as the name suggests, it is a normal object Person. // By default, all the objects will automatically get a prototype constructor (constructor) property, which (a pointer) to functions (Person) prototype property is located Conclusion: The prototype object (Person.prototype) is the constructor (Person) of an instance. The second 4, __ proto__ JS when you create an object (whether ordinary object or function object), there is a built-in properties named __proto__ for point to create its prototype object constructor. The Person == Person.prototype.constructor; PERSON1 .__ proto__ == Person.prototype; person1.constructor == the Person; . 5, the constructor familiar Javascript shoes know, we can create an object: var obj = {} which is equivalent such below: var obj = new new Object () obj is an instance constructor (Object) is. So: obj.constructor === Object obj .__ === Object.prototype proto__ Similarly, you can create an object constructor not have Object, can also be a Array, Date, Function, String, Boolean, Number, and so on. So we can also constructor to create Array, Date, Function, these are the constructor function object 6. prototype chain Object.prototype .__ proto__ === null; Part III 7. function object proto are all function object // point Function.prototype, which is a function empty (empty function) // constructor are all derived from Function.prototype, even including the root itself constructor Object and function Number the .__ proto__ to true // === the Function.prototype Number the. == Function to true // constructor Boolean .__ proto__ to true // === the Function.prototype Boolean.constructor == Function to true // // constructor are all derived from Function.prototype, even including the root itself constructor Object and Function === Function.prototype proto__ .__ // Object to true Object.constructor to true // == Function // constructor all come from Function.prototype, even including the root Object constructor itself and Function Function .__ proto__ === Function.prototype // to true Function.constructor == Function to true // Array .__ === Function proto__ to true // .prototype Array.constructor to true // function == a Date .__ proto__ to true // === the Function.prototype Date.constructor to true // function == // function declaration function the Person () {} // function expression Perosn function = var () {} the console.log (proto__ the Person .__ === the Function.prototype) to true // ** all constructors are derived from Function.prototype, even including the root and function Object builder itself. All constructors inherit properties and methods · · Function.prototype of. The length, call, apply, bind ** // Function.prototype only a typeof XXX.prototype for the function of the prototype. Other prototype constructor is an object of the console.log (typeof the Function.prototype) // function the console.log (typeof Object.prototype) // Object the console.log (typeof Number.prototype) // Object the console.log ( Boolean.prototype typeof) Object // console.log (typeof String.prototype) Object // console.log (typeof Array.prototype) Object // console.log (typeof RegExp.prototype) Object // console.log (typeof Error .prototype) Object // console.log (typeof Date.prototype) Object // console.log (typeof Object.prototype) // Object knew all constructors __proto__ (with built-in and custom) is Function. prototype, who is it that Function.prototype of __proto__? I believe all heard the JavaScript function is also first-class citizens, then how can reflect from it? As console.log (Function.prototype .__ proto__ === Object.prototype) // true, indicating that all constructors are also a common JS object to the constructor may add / delete attributes. It also inherits all the methods on the Object.prototype: toString, valueOf, hasOwnProperty such as who last Object.prototype of proto is? Object.prototype .__ proto__ === null has peaked, and is null. (Read now, go back and look at the fifth chapter, can understand it?) 8, prototype all function objects proto point Function.prototype, it is an empty function (Empty function) Object.getOwnPropertyNames (Function.prototype) so all function objects can use 9, review the eighth section we summarize: __proto__ all function object point Function.prototype, it is an empty function (empty function) but you can not forget the third section we summarize of: __proto__ all objects point to its constructor the prototype 10, the prototype chain (at refresher) function the Person () {} var = new new PERSON1 the Person (); the console.log (PERSON1 .__ proto__ === Person.prototype); // to true console.log (Person.prototype .__ proto__ === Object.prototype) to true // console.log (Object.prototype .__ proto__) // null the Person .__ proto__ == Function.prototype; // to true console.log (Function. prototype) // function () {} ( empty function) var new new NUM = the Array () the console.log (NUM .__ proto__ == Array.prototype) to true // the console.log (Array.prototype .__ proto__ == Object.prototype ) to true // the console.log (Array.prototype) // [] (empty array) the console.log (Object.prototype .__ proto__) // null the console.log (the array .__ proto__ the Function.prototype ==) to true // doubt FAQ: 1,Object.__proto__ === Function.prototype // true Object is a function of the object, through new function () to create, so the Object .__ proto__ point Function.prototype. (Refer to Section VIII: "All __proto__ function object point Function.prototype") 2, Function .__ proto__ === Function.prototype // true Function is a function of the object, is created by the new Function (), so the Function .__ proto__ point Function.prototype. 3, Function.prototype .__ proto__ === Object.prototype // true fact that I have a little confused, but you can try to explain. Function.prototype is a function of an object, in theory, he should point __proto__ Function.prototype, it is his own, pointing to own their own, does not make sense. JS has always stressed that all things are objects, function objects are objects, give him admit you were fathers, point Object.prototype. Object.prototype .__ proto__ === null, the prototype chain can guarantee the end of normal. 11, summed up the prototype chain is a model and prototype JS implementation inheritance. Form prototype chain is not really __proto__ by the prototype var Animal = function () {}; var Dog = function () {}; animal.price = 2000; Dog.prototype = Animal; var = Tidy new new Dog (); the console.log (Dog .price) // undefined console.log (tidy.price) // 2000 var Dog = function () {}; dog.prototype.price = 2000; var = Tidy new new Dog (); the console.log (tidy.price); // 2000 the console.log (dog.price); // undefined var Dog = function () {}; var = Tidy new new Dog (); tidy.price = 2000; the console.log (dog.price); // undefined example (Tidy) and prototype object (Dog.prototype) a connection exists. However, to clear the really important point is that this connection exists between the prototype object instance (tidy) and constructor (dog.prototype), rather than between instances (tidy) and constructor (dog). Comments: 1, most bloggers have analyzed it, the prototype chain is not clear, leading to comments misunderstanding, no instances of property, js will try to find the prototype object, not the prototype object, go down to the prototype object __proto __ (Object.prototype) looking on, Eventually find Object.prototype._proto_ (he is the prototype chain end null), find the corresponding value is returned, did not find returns undefined 2, just listened to my colleagues on the next, suddenly, is a prototype object, is a create their own prototype object, it can be understood as the level. Note: </ Script> </ HTML>