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

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

SQL Server - MyCTE query based on 24 hour period (next day) -

php - Using str_replace to translate a MySQL Table in html -