1.構建類:
JS中構建類,其實就是構建類的一個構造方法。如下:
{
this .name = " aaa " ;
this .b = " bbb " ;
this .sayHello = function ()
{
alert( " welcome: " + this .name);
}
};
var foo = new Foo();
foo.name = " wh " ;
foo.sayHello();
var locate1 = "1oh";
this.locate2 = "2oh";
var method1 = function(){
alert(locate1);
}
this.method2 = function(){
alert(this.locate2);
method1();
}
}