哦 我是在本地 火狐浏览器上运行的 ,我的源代码是:
document.write("<br />");
function book(name,type,price){
this.name = name;
this.type = type;
this.price = price;
//this.showBookInfo = function(){
// document.write("书名:"+this.name+"\t"+"类别:"+this.type+"\t"+"价格:"+this.price+"\t");
// }
}
book.prototype.showBookInfo = function (){
document.write("书名:"+this.name+"\t"+"类别:"+this.type+"\t"+"价格:"+this.price+"\t书店:"+this.bookstore+"\t");
}
book.prototype.bookstore = "新华书店";
var book1 = new book("《选集》","社科类",35.00);
//book1.showBookInfo();
document.write("<br />");
book.prototype.bookstore = "新华文轩书店";
var book2 = new book("javascript","工科类",45.05);
运行结果是:
书名:《选集》 类别:社科类 价格:35 书店:电子科大书店
书名:javascript 类别:工科类 价格:45.05 书店:电子科大书店