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

Is slice necessary here? #147

Closed samreid closed 3 years ago

samreid commented 3 years ago

From a TODO in https://github.com/phetsims/axon/issues/279

this.transientParticlesBackup.addAll( this.transientParticles.slice() ); // TODO: https://github.com/phetsims/axon/issues/279 is slice necessary here?

Assigning to responsible dev.

jbphet commented 3 years ago

No, I don't believe the call to slice is needed. The addAll method uses the spread operator, so no additional copy of the array is necessary.

I verified that the functionality was correct after removing the call to slice by stimulating the neuron with the potential chart visible and periodically grabbing the playback marker and moving it backwards in time. I used console.log to verify that the code above was being called. It all seemed to work fine.

Closing.