Posts

Showing posts with the label setInterval

JQuery Timer Library

I have been working on game development for the past month. Building game logic is pretty fun, but the need for a good JavaScript timer was needed. Having done a few searches online, I've found Matt Schmidt JQuery Timer plugin v0.1. Out of the box it does everything I want, but there was one issue that was becoming evident.  JQuery Timer uses JavaScript  setInterval which basically recursively calls the code in the block as shown below          $ . timer ( 1000 , function ( timer ) {                 console . log ( Hello World ! ');             }); In the above block of code, Hello World! is outputted to the console every minute… What if we wanted to display Hello World only once?          $ . timer ( 1000 , function ( timer ...