Javascript Execution Order - When Window.location.href Happens?
I took a look at this is-javascript-location-href-call-is-asynchronous and this what the heck is the event loop anyway but there is no explanation of the defined behavior of href o
Solution 1:
Stop. Research Javascript Event Loop. JS executes code linerly. When an event - asynchronous call generally speaking - is encountered it is pushed to an "event queue" and JS execution keeps going. The event queue is 'first in, first out'. There's no telling what is in the queue at any moment so the execution of any given event - your href - is unpredictable - it is not 'by chance.' If program execution was 'by chance', then computers would not even work.
Post a Comment for "Javascript Execution Order - When Window.location.href Happens?"