Javascript_ constructor/prototype/instance object relationships

Source: Internet
Author: User


1. All instance objects have implicit prototype properties.
2. Each functional function has a prototype display prototype property.
3. The value of the object's implicit prototype is the value of its corresponding constructor's explicit prototype.
4. The prototype property of the function: automatically added when the function is defined, and the default value is an empty object object.
5. The object'sProtoProperties: Automatically added when an object is created, the default value is the prototype property value of the constructor.
6.function foo{} equals var Foo = new function () so there are implicit prototype properties, that is, all functions have implicit and display prototype properties.
7. The implicit prototypes of all functions are equal and are generated by the new function.
The 8.function function () has both a display prototype attribute and an implicit prototype attribute and the same, indicating function=new function.
The implicit prototype of the 9.function Object () is equal to the display prototype of the function function, further explaining that each of the functions is an instance of the functionality (including himself).
10. The display prototype of the function points to an object that is empty by default, and the single object is not satisfied.
Note: The display prototype of function is also an instance of object
The 11.Object prototype object is the end of the prototype chain, which is null

function Fn(){            this.test1 = function(){                console.log(‘test1()‘);            };        }        Fn.prototype.test2 = function(){            console.log(‘test2()‘);        };        var fn = new Fn();        console.log(Fn.prototype instanceof Object)//true        console.log(Object.prototype instanceof Object)//false        console.log(Function.prototype instanceof Object)//true        console.log(Function.__proto__===Function.prototype)//true        console.log(Object.prototype.__proto__)//null

Javascript_ constructor/prototype/instance object relationships

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.