这是我尝试执行的示例代码。
var Game = function(){
this.state = 'yeah';
}
Game.prototype.call = function(){
document.writeln(this.state);
Game.prototype.say();
}
Game.prototype.say = function(){
document.writeln(this.state);
}
game = new Game();
game.call();
结果是yeah undefined
这意味着call()
正常工作 而say()
不是。我可以为say()
函数做些什么才能从 Game 对象中获取 this.state?