javascript - Node.js: running setInterval while certain variable is true? -


i have setinterval function , isrunning variable. how stop setinterval when isrunning gets set false?

thanks.

see comments inline:

var isrunning = true; // define outside can accessed inside setinterval  var interval = setinterval(function() {     // code here       // check if variable false, clear interval     if (isrunning == false) {         clearinterval(interval);     } }, 100); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

javascript - How to display image with fancybox href attribute -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -