var pen = function(name,color,price){
this.name = name;
this.color = color;
if(price == undefined){
this.price = 9.9;
}
else{
this.price = price;
}
}
var Rpen = new pen("Mao","Blue",200);
var Bpen = new pen("Zhao","Red")
console.log(Rpen.name+"\n"+Rpen.color+"\n"+Rpen.price+"\n");
console.log(Bpen.name+"\n"+Bpen.color+"\n"+Bpen.price);
来源:CSDN
作者:EdmundMao
链接:https://blog.csdn.net/weixin_43635647/article/details/104097136