Class: Divided into public and private
function Person( n){
var name=n; //Private attribute
function hello(){} //Private method one
var hello2() = function(){} //Private method two
this.Name = "Zhang San"; //Public member one
this.Hello = function(){ //Public method one
this.Name; //Private methods and properties can be called in the public method
name;
}
}
Person.prototype.Age=20; //Public member two
Person.prototype.SayHi = function(){} //Public method two
var p = new Person("abc");
p.ShowAge=function(){ //Public method three
this.Age;
}
p.Gender="M"; / /Public member three
Inherited:
function Person(args){ //Parent class
this.Name = "李思";
}
function Studnt(a,b,c){ //Subclass
Person.apply(this,arguments); //Skill method one
Person.call(this,a,b,c); //Skill method two
}