当我运行以下代码时,出现错误:TypeError: Object [object Object]
// create your Animal class here
function Animal(name, numLegs)
{
this.name = name;
this.numLegs = numLegs;
}
// create the sayName method for Animal
Animal.prototype = function sayName()
{
console.log("Hi, my name is [name]");
};
// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();
为什么?