Darwin's theory of evolution vs Plato's Philosophy

Source: Internet
Author: User

Each object in JS has a __proto__ property, and each function (function is also an object) has a natural, but the function also has a prototype property.

function A () {this.x=0;} var a=new a (); alert (A.__proto__===a.prototype)//true

the above constructors are equivalent to doing these three things:

1. Create an Object a={}
2. Initialize it, A.call (a)
3. Assign a value to the A.__proto__ property: A.__proto__=a.prototype

When a calls a property that it does not have, it goes to a.__proto__, which is the same name attribute in A.prototype.

Here's an interesting example:

function A () {}a.prototype.v=1;var a=new A ();//a.__proto__ point to A.prototypea.prototype={v:2};var a2=new A ();//A2.__proto __ points to the new a.prototype, but a.__proto__ does not change alert (A.V);//1alert (A2.V);//2



Plato believed that the creator created the world with the idea of the world as a blueprint or model. If the concept of Java classes and objects is likened to Plato's theory of ideas, JS can be likened to Darwin's theory of evolution. JS does not have the concept of class, each object can have more or less variation

Darwin's theory of evolution vs Plato's Philosophy

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.