所有实例化对象享用prototype里面的方法和属性。

function book() {
    this.type = type;
}
book.prototype = { price: 21};

var A = new book();
var B = new book();

A.price;     //21
B.price;     //21

 

 

相关文章:

  • 2022-12-23
  • 2019-03-18
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-12
  • 2021-06-08
  • 2019-10-21
  • 2021-11-11
  • 2021-07-07
相关资源
相似解决方案