js实现公用、私有、静态方法属性function Student(name,sex) {this.name name//公有属性this.sex sexv
js实现公用、私有、静态方法属性
function Student(name,sex) { this.name = name;//公有属性 this.sex = sex; var message = "心理想法";//私有属性 this.say = function (){//公有方法:即可以访问私有、公有的方法和属性 alert("姓名"+this.name); alert("年龄"+this.sex); alert(message); } var privateMethod = function(){//只能访问私有的方法和属性 alert(message); }}js静态方法
Student.go = function(){ alert('行走');}Student.go();js静态属性
Student.hand = '123';alert(Student.hand);
