Class: divided into public and private
CopyCodeThe Code is as follows: function person (n ){
VaR name = N; // Private Attribute
Function Hello () {}// private method 1
VaR hello2 () = function () {}// private method 2
This. Name = "James"; // public member 1
This. Hello = function () {// public method 1
This. Name; // Private methods and attributes can be called in public methods.
Name;
}
}
Person. Prototype. Age = 20; // publish Member 2
Person. Prototype. sayhi = function () {}// method 2
VaR P = new person ("ABC ");
P. showage = function () {// method 3 to publish
This. Age;
}
P. Gender = "M"; // public member 3
Inheritance:Copy codeCode: function person (ARGs) {// parent class
This. Name = "Li Si ";
}
Function studnt (a, B, c) {// subclass
Person. Apply (this, arguments); // skill method 1
Person. Call (this, A, B, C); // skill method 2
}