js--Object-oriented

Source: Internet
Author: User

Object oriented

The most mainstream programming paradigm (JS does not enforce object-oriented) in the form of a noun encapsulation description

Class/constructor

The code that describes the object, and also the template that describes an object

This can be used inside the constructor relative to the normal function, and new initialization is required

function A () {  this. a=1  } 
Create

Use new to create

var a=New A ();

After using the new command, its function passes through a ' wrapper ': first create an empty object, which is assigned to the This keyword inside the function as a context object. In other words, this refers to a newly generated empty object, and all operations against this will occur on this empty object.

A constructor is called a constructor, which means that the purpose of the function is to manipulate the context object (the This object) and "construct" it as needed. If the return statement of the constructor returns an object, the new command returns the object specified by the return statement, otherwise it returns the constructed context object regardless of the return statement.

js--Object-oriented

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.