JS类的声明其实就是一个function
function user(){
//Java 语言的Public
this.Name ="Maoyeye";
this.age = 110;
//var 就相对于高级语言中的private
var email ="cswangbin@163.com"
this.getEmail = function(){
return email;
}
}
var u= new user();
alert(u.Name + u.getEmail())
第二方式,先JSON形式声名
new person = {
name:‘Mao爷爷’,
age:110
};
//用.或[]引用
alert(person.name+person[age])