JS Object-Oriented notes

Source: Internet
Author: User

JS Object-Oriented composition is

1. Properties

2. Methods

It is used to add attributes to the constructor and add the method to the prototype.

If it is directly inside the constructor: passing a value, creating a new object, adding a property/method, or returning an object can cause problems, mainly

1. No new

2, the function repeats the definition, this can let the resources waste

So, we're going to use this construct property inside the constructor to put the method in the prototype.

If we rewrite the process-oriented function as an object-oriented function, we need to solve the function nesting, then transform the variable into a property, convert the function into a method,

Call to New.

Assuming b inherits a, if the method that does not let B increase first also affects a, the method of inheritance is as follows

 for (var in a.prototype) {    = a.prototype[i];}

JS Object-Oriented notes

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.