用JS用面向对象实现一个JS对象。对象里有两个属性,一个方法

如题所述

function MyObject(){
this.name = "myObject";
this.type = "class";
this.methodA = function(){
alert(this.name);
}
this.methodB = function(){
return this.type;
}
}
var myObject = new MyObject();
myObject.methodA();
var type = myObject.methodB();
alert(type);

温馨提示:答案为网友推荐,仅供参考
相似回答