You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • @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...

About

Avatar for allObjects @allObjects started