Defined
function person (national,age)
{
this.age = age; instance objects, with each example different
person.national = National; Class object, used instance public
var bb = 0;//local variable, outside inaccessible (similar to local function)
}
Call
var p = new Person ("China");
Document.writeln ("Age:" + p.age);
Document.writeln ("Object National:" + p.national);
Document.writeln ("Class National:" + person.national);
Document.writeln ("Local var:" + p.bb);
var p2 = new Person ("USA");
Document.writeln ("</br>");
Document.writeln ("Age:" + p2.age);
Document.writeln ("Object National:" + p2.national);
Document.writeln ("Class National:" + person.national);
Document.writeln ("Local var:" + p2.bb);
Document.writeln ("</br>");
Document.writeln ("Class National:" + person.national);
Age:29 object national:undefined Class National: China local var:undefined
//age:31 object national:undefined class National: United States local var:undefined
//class National: United States
This article on the JS function of the instance object, class object, local variables (local function) is small to share all the content of everyone, hope to give you a reference, but also hope that we support the cloud habitat community.