87,923
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
var ioldFish = function(name,age){
return ioldFish.func.init(name,age);
};
ioldFish.func = ioldFish.prototype ={
init:function(name,age){
this.name = name;
this.age = age;
return this;
},
showInfo:function(){
var info = "my name is" + this.name +"i am " +this.age+"years old";
alert(info);
}
};
ioldFish.func.init.prototype = ioldFish.func;
ioldFish(" 老 鱼",27).showInfo();
//var oldFish = new ioldFish("老鱼",27);
//alert(oldFish.name);
</script>
ioldFish.func.init.prototype = ioldFish.func;
ioldFish.func = ioldFish.prototype
function ioldFish(name,age){
this.init(name,age);
};
ioldFish.prototype ={
init:function(name,age){
this.name = name;
this.age = age;
},
showInfo:function(){
var info = "my name is" + this.name +"i am " +this.age+"years old";
alert(info);
}
};
new ioldFish(" 老 鱼",27).showInfo();