javascript 面向对象例子
http://www.cnblogs.com/johnson2008/archive/2008/05/15/1198252.html
http://www.cnblogs.com/syuko/archive/2008/03/05/1091843.html
http://www.cnblogs.com/syuko/archive/2008/03/18/1110210.html
http://www.cnblogs.com/syuko/archive/2008/03/19/1113063.html
function Flower(){
//公有属性
this.name="rose";
this.color="red";
//私有属性
var privateProp="test";
this.total=function total(n){
return n*5;
}
/*
也可以这样写
this.total=function total(n){
return n*5;
}
*/
this.alertPrivate=function(){
alert(privateProp);
}
}
var obj=new Flower();
alert(obj["name"]);
alert(obj.color);
alert(obj.total(4));
//undefined
alert(obj.privateProp);
obj.alertPrivate();