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