我正在执行以下代码。
获得以下输出:
function Person(name, age){
this.name = name || "John";
this.age = age || 24;
this.displayName = function(){
console.log('qq ',this.name);
}
}
Person.name = "John";
Person.displayName = function(){
console.log('ww ',this.name);
}
var person1 = new Person('John');
person1.displayName();
Person.displayName();
获得以下输出:
qq John
ww Person
我不明白为什么在第二个控制台中会得到 this.name = Person。