phetsims / neuron

"Neuron" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
1 stars 3 forks source link

Use `this` where appropriate #131

Closed samreid closed 8 years ago

samreid commented 8 years ago

In some contexts, the closure variable self is used instead of this, which is somewhat confusing.

  function DelayBuffer( maxDelay, minTimeStep ) {
    var self = this;
    self.numEntries = Math.ceil( maxDelay / minTimeStep ); // @private
    self.filling = false; // @private
    self.allDeltaTimesEqual = true; // @private
    self.previousDeltaTime = -1; // @private
    self.countAtThisDeltaTime = 0; // @private
    // Allocate the memory that will be used.
    self.delayElements = new Array( this.numEntries ); // @private
jbphet commented 8 years ago

Done, closing. This touched a lot of files - I think the original author of the port had the philosophy of setting up a self var at the top of the file and using it everywhere. I'll make sure I put a note in the development guidelines that this is not our standard.