I’ve always been confused by the terms synchronous vs. asynchrous in Javascript, as they seem to mean just the opposite of what they would mean in the real world. I always thought that synchronous meant multiple things could happen at once, and asynchrous means only one thing can happen at a time.
According to dictionary.com, I get the following meanings:
asynchronous: not occurring at the same time.
synchronous: occurring at the same time; coinciding in time; contemporaneous; simultaneous.
From the MDN developer site, I get the following definitions:
asynchronous: Asynchronous refers to a communication environment where each party receives and processes messages when convenient or possible rather than immediately.
It can be used to describe a human communication environment like e-mail — the sender will send an e-mail, and the recipient will get round to replying to it when convenient; they don’t have to reply immediately.
It can also be used to describe a programatic communication environment, for example Ajax is an asynchronous mechanism for requesting small bits of data over HTTP; the result is sent back when the response is complete, not immediately.
synchronous:Synchronous refers to real-time communication where each party receives (and if necessary, processes and replies to) messages instantly (or as near to instantly as possible).
A human example is the telephone — during a telephone call you tend to respond to another person immediately.
Many programming commands are also synchronous — for example when you type in a calculation, the environment will return the result to you instantly, unless you program it not to.
When comparing here, I get a better understanding. While Javascript is non-blocking (i.e. it doesn’t hold up execution while a piece of code runs), things are happening one at a time, just not necessarily sequentially. According to the dictionary, sychronous means multiple things happening at once, while in Javascript it means something happens instantly (but not multiple things simultaneously).