@Gordon, didn't you recently add .bind()? Would that now be even a better option - resource-wise - and for sure from a point of avoiding globals...?
I guess the code would then look like this:
Wheel.prototype.spin = function(stopt) // stopt = stoptime { this.vel = (2 + Math.random() * 5) / 40; // give the wheel a velocity setTimeout(this.stop.bind(this), stopt); // tell it when to stop };
Adding this .bind() was a great move! Still have to get used to it having started JS with 1.3...
@allObjects started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Gordon, didn't you recently add .bind()? Would that now be even a better option - resource-wise - and for sure from a point of avoiding globals...?
I guess the code would then look like this:
Adding this .bind() was a great move! Still have to get used to it having started JS with 1.3...