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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -