1, object-oriented
What is the object: the object is used to describe a whole of things all the information
object has properties and methods (characteristics)
What is object-oriented: oop is a programming idea, reflecting the logic of life
The difference between process-oriented and object-oriented
process-oriented : that is, to analyze the steps required to solve the problem, then use the function to implement these steps, step by step, when used in a call to a turn on it.
Object-oriented : the transaction is to be a problem down into objects, the object was not intended to establish a complete step, but a thing to Miao Xu behavior throughout the problem-solving steps in.
For example: a car speed of 200 km long highway how long it takes to walk the distance 100 / hour?
Object-oriented disadvantages:
disadvantages: high costs and long development cycle
advantages:
functionally independent of management and maintenance easy to post
contamination preventing global variables
Object-oriented three characteristics: encapsulation inheritance polymorphism (js no)
What is the class (constructor)? Class is the general term for a class of things has the same properties and behavior of
the relationship between classes and objects:
class is an abstract object (the class is an object abstraction)
object is a class of the concrete of (object instance of the class)
prior to abstracting out of the concept of a class
But when writing code using the object-oriented thinking, after the first write constructor (class) write objects
such as:
Array new Array()
2. Create Object
1, to create objects using {}
2, new Object () to create objects
such as: create 10 student objects
stu1 = new Object();
//添加属性和方法
stu2 = new Object();
//添加属性和方法
The disadvantage of the above two methods to create an object: creating a plurality of objects of the same code is repeated when
3, create objects using the constructor
es6:
class 函数名{
constructor(){
}
方法名(){
}
}
es5:
create a constructor
function 函数名(){
}
Features constructor:
function name constructors recommend using a large hump format
constructor of this new pointing out the object constructor