The design idea of JavaScript inheritance mechanism

Source: Internet
Author: User
Tags inheritance

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/

Related Article

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.