The difference between JavaScript object-oriented and traditional object-oriented

Source: Internet
Author: User

1. JavaScript's object-oriented is prototype-based;


2. JavaScript is a function to represent the class, but this function can use this, you can declare properties and methods inside;

You can also say upside down, if a common function uses the This keyword, then this function is a class, it must be called in the form of an object;


3. The so-called object is actually a constructor (like a normal function) plus a new keyword,

If there is no new keyword, then this constructor is a normal function. In the Declaration of objects, JavaScript is the same as the traditional object-oriented;


4. The member property in the JavaScript class is private to all objects, which is the same as the traditional object-oriented, that is, the member property belongs to the object;

5. The Member method of JavaScript is also private, that is, each object will save the independent member method in memory, so its member method is also private, belongs to the object;

6. The traditional object-oriented member methods belong to the entire class, and each object has the same reference address to the member method, that is, the method is shared for all objects;

7. JavaScript introduces a "prototype" approach that implements similar functionality as traditional object-oriented. Because one of the biggest features of "prototypes" is "sharing."


This article is from the "Everything Possible" blog, please be sure to keep this source http://noican.blog.51cto.com/4081966/1629900

The difference between JavaScript object-oriented and traditional object-oriented

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.