JS Object-oriented

Source: Internet
Author: User

Write code in the form of an object (simple and straightforward)

The common notation is called a procedural notation,

Object-oriented features

Abstraction (extracting the same thing or method);

Encapsulation (can only be used by objects in the method of the object);

Inheritance (re-use method);

An object-oriented basic notation

The composition of the object

Instance:

var arr= "";//Create an array, also an object

The variable under the Arr,number=10;//object is the property of the object

Test method under Arr.test=function () {//arr

alert (123);

}

Arr.test ();//Call the test method under Arr

alert (Arr,number); POPs the property value of the Number property under Arr

How are properties and methods resolved?

Attributes are only used, purely object-point attributes

Method whenever it is called, the parentheses are added

Object-oriented instances:

Var obj=new object ();//Create an empty object equivalent to obj={}

Obj.name= "Xiao Ming";

Obj.showname=function () {

Alert (1)

}

Factory mode (functional object-oriented)

Factory Mode: Encapsulation function

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.