Synchronous vs Asynchronous
First let’s define them in easy way to understand them, Two or more things are synchronous when they happen at the same time, and asynchronous when they don’t.
Synchronous code is a code which line of codes run in sequence order.
Asynchronous code is different from that which it allows the code which is written write after that to be executed immediately without waiiting.
Let me give an example imagine you are in a queue and you are waiting for your turn in queue to order something you should wait for all people which came before you to order their stuffs. This example is kind of the same as ruuning some Synchronous code.
Now imagine you are in a resturant and you want to order something, you don’t have to wait for all other people who came before you to finish their food to order your food at the same time that they’re eating you can order. That’s like Asynchronous code.
Now let’s talk about this concept in JS, as we know JS is single threaded but it allows Asynchronous code! So what does it mean then? It means that we have cuncurrency but we don’t have parallelism here. Like if it is fast enough it can switch between different task efficiently enough so diffrent stuff are making progress.