Search Results

Search found 1 results on 1 pages for 'dagoof'.

Page 1/1 | 1 

  • JavaScript setTimeout setInterval within one function

    - by dagoof
    I think I might be overtired but I cannot for the life of me make sense of this, and I think it's due to a lack of knowledge of javascript var itv=function(){ return setInterval(function(){ sys.puts('interval'); }, 1000); } var tout=function(itv){ return setTimeout(function(){ sys.puts('timeout'); clearInterval(itv); }, 5500); } With these two functions I can call a=tout(itv()); and get a looping timer to run for 5.5 seconds and then exit, essentially. By my logic, this should work but it simply is not var dotime=function(){ return setTimeout(function(){ clearInterval(function(){ return setInterval(function(){ sys.puts("interval"); }, 1000); }); }, 5500); } any insight in this matter would be appreciated.

    Read the article

1