setInterval establishes a repeating timer. It returns a manage that you can enter
clearInterval to quit it from shooting:
var take care of = setInterval( drawAll, 20);. // When you intend to terminate it:. clearInterval( take care of);. take care of = 0;// I simply do this so I understand I have actually removed the period.
On internet browsers, the take care of is assured to be a number that isn’t equivalent to
0; for that reason,
0 makes an useful flag worth for “no timer collection”. (Various other systems might return various other worths; Node.js’s timer features return an item, for example.)
To arrange a feature to just fire when, usage
setTimeout rather. It will not maintain shooting. (It likewise returns a manage you can make use of to terminate it by means of
clearTimeout prior to it discharges that a person time if proper.)
setTimeout( drawAll, 20);.