Process oriented:
According to the logical writing, conforms to the computer execution thought. There is a clear start and end, and the process of implementing the intermediate gradually.
Object-oriented:
Look at objects from a human point of view, have subjectivity, different people, face the same object, get different properties and methods
A class is an abstraction of an object that is an instance of a class
JS No class concept, only the concept of the prototype
Instances of classes in other languages can only use properties and methods that are defined first by the class, and cannot be modified
JS can add properties and methods to an object dynamically, but only if the object has added properties and methods, properties and methods added for the prototype, all objects of that prototype have added properties and methods
I. Creating an Object
function people (Name,age) {
This.name=name;
This.age=age;
This.getname=function () {
return this.name;
}
}
Two. Calling objects
var peo= new people ();
Alert (peo.name+ "," +peo.age+ "," +peo.getname ");
Three. Object inheritance
1. Impersonation inheritance
Object impersonating law one:
This.inherit=people;
This.inherit (Name,age);
Delete This.inherit;
Object Impersonating Law II:
People.call (this,name,age); parameter comma delimited
Object Impersonating Law III:
People.apply (This,[name,age]); parameters are passed in an array
2. True inheritance: Prototype chain inheritance
Man.prototype = new People ();
Funciotn Man (name,age) {
This.constructor (name,age); Call the constructor of the parent class to pass the argument
}
JS Object-oriented