Me pueden explicar lo siguiente teniendo:
/* MenuCommand class, a command object. */
var MenuCommand = function(action) { // implements Command
this.action = action;
};
MenuCommand.prototype.execute = function() { this.action(); };
If the action method uses the this keyword internally, it has to be wrapped in an anonymous function. Here is an example of that:
var someCommand = new MenuCommand(function() { myObj.someMethod(); });
Por qué si se utiliza this
se debe usar una función anónima al pasar la función como parámetro