Quick question regarding settimeout, does it execute periodically like setinterval?
Say I have a line that goes like setTimeout("functionx();" , 1000) ,
is functionx() executed only once (after 1 second)? or does it go like this:
- 1 sec delay
- run functionx()
- execute functionx every 1 second after that?
thanks
setTimeoutis a one-off, the function you give it is called only once.(Off-topic: Note that you almost never want to give either
setTimeoutorsetIntervala string containing code; instead, give it an actual function reference.)So this will call the function
fooonce, after half a second or so (these things are not precise):…whereas this will keep calling it every half second or so until you stop it: