📜  什么是 fn.call - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:52.879000             🧑  作者: Mango

代码示例2
function Product(name, price) {
  this.name = name;
  this.price = price;
}

function Food(name, price) {
  Product.call(this, name, price);
  this.category = 'food';
}

function Toy(name, price) {
  Product.call(this, name, price);
  this.category = 'toy';
}

const cheese = new Food('feta', 5);
const fun = new Toy('robot', 40);