Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

when is javascript synchronous

when is javascript synchronous  using -'javascript,jquery'

I have been under the impression for that JavaScript was always asynchronous.  However, I have learned that there are situations where it is not (ie DOM manipulations).  Is there a good reference anywhere about when it will be synchronous and when it will be asynchronous?  Does jQuery affect this at all?

asked Sep 14, 2015 by Iona71Loziqn
0 votes

Related Hot Questions

Government Jobs Opening

Now run the webpage and click on the webpage, and see the output on console. The output will be

wait() context will be popped after this line
global context will be emptied after this line
click event handler...

What is happening is JavaScript engine is running the code synchronously as explained in the execution context portion, the browser is asynchronously putting things in event queue. So the functions which take very long time to complete can interrupt event handling. Things happening in browser like events are handled this way by JavaScript, if there is a listener supposed to run, engine will run it when the execution stack is empty. And events are processed in order they happen, so the asynchronous part is about what is happening outside the engine i.e. what should the engine do when those outside events happen.

So JavaScript is always synchronous.

answered Sep 14, 2015 by EnrTebbutt