Is the following usage of clearInterval() and setInterval() bad in any way? If so, in what situation?
var myInterval;
if (spaceData.pushed == 1) {
clearInterval(myInterval);
[...some code...]
}
else {
myInterval = setInterval(function() {
[...some other code...]
},1000/60);
}
What the code does is that it executes some code when the spacebar har been pushed and some other code when the spacebar has been released.