Here is the sample code that I am trying to execute.
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();
The result is yeah undefined which means that the call() is working properly while the say() isn't. What can I do for say() function to be able to get this.state from Game object?
.call(). While it technically may work in some circumstances, it could really confuse people withFunction.call()which every function has already.writelnas if the document is closed (e.g. after the load event has been dispatched), it will first calldocument.openwhich will clear the document of existing content.