It's been hard for me to understand the inheritance mechanism of JavaScript language.
It does not have the concept of "subclass" and "parent", and there is no distinction between "class" and "instance" (instance), which relies on a peculiar "prototype chain" (prototype chain) pattern to implement inheritance.
I spent a lot of time studying this part and taking a lot of notes. But all belong to the forced memory, can not fundamentally understand.
It was not until yesterday that I read the explanation of the French programmer, Vjeux, that I understood exactly why JavaScript was designed.
Next, I try to explain its design ideas in my own language. Tell me exactly what's going on with the prototype object. It's not that complicated at all, but the truth is simple.
First, speaking from ancient times
To understand the design of JavaScript, we must begin with its birth.
1994, Netscape (Netscape) released the Navigator browser version 0.9. This is the first more mature web browser in history, hit. However, this version of the browser can only be used to browse, do not have the ability to interact with visitors. For example, if the page has a column "user name" required to fill out, the browser can not determine whether the visitor is really filled out, only let the server-side judgment. If not filled out, the server side returns an error, requiring the user to fill in, which is too waste of time and server resources.
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/script/