为什么这样做:
speak
但这不起作用?
function Animal(name) {
this.name = name;
this.speak = function() {
console.log("My name is " + this.name);
}
}
var animalA = new Animal();
var animalB = new Animal();
animalA.speak === animalB.speak // false
由于某些原因,添加库限定符(应该更具描述性)会导致类型不匹配。与这两种工作不同:
function Animal(name) {
this.name = name;
}
Animal.prototype.speak = function() {
console.log("My name is " + this.name);
};
var animalA = new Animal();
var animalB = new Animal();
animalA.speak === animalB.speak // true
答案 0 :(得分:0)
我想我只是想通了。看起来WorksheetFunction实际上是Excel库的成员,但是应用程序对象的属性