javascript関数における例示的なオブジェクト、クラスオブジェクト、ローカル変数(局所関数)
2596 ワード
定義
呼び出し
function Person(national,age)
{
this.age = age; // ,
Person.national = national; // ,
var bb = 0; // , ( )
}
呼び出し
var p = new Person(" ", 29);
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(" ", 31);
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: local var:undefined
//age:31 object national:undefined Class national: local var:undefined
//Class national: