Real asynchronous javascript function -
does
settimeout(function () { /*logic*/ }, 0); really makes function asynchronous?
no not.
it places function on event queue given delay (here delay of zero). if there other functions queued execution, gets placed behind them , has wait until (including active) functions executed.
to test this, ethis
console.log( 'start' ); settimeout(function () { console.log("timeout"); }, 0); // long running code console.log( 'end' ); you still output:
start
end
timeout
Comments
Post a Comment