You are reading a single comment by @d3nd3-o0 and its replies. Click here to read the full conversation.
  • To my understanding of javascript, asynchronous-like behaviour from timeout is meant to run when execution stack is empty. I expect output with 'nope' at the bottom of the list. Why is this happening? Im running in the 'web ide' with emulator mode. Tested on my bangle watch connected to the ide too, same.

    setTimeout( function(){console.log("nope");},0);
    console.log("yep");
    console.log("yep");
    console.log("yep");
    console.log("yep");
    console.log("yep");
    var dontgetit = 345;
    

    OUTPUT:

    >yep
    nope
    >yep
    >yep
    >yep
    >yep
    

    another example :

    setTimeout( function(){console.log("nope");},100);
    var x =0;
    while ( x < 10000 ) {
      x++;
    }
      
    var dontgetit = 345;
    console.log("done");
    
About

Avatar for d3nd3-o0 @d3nd3-o0 started