Synchronous code can be useful for operations that don't require much processing time or when the order in which the operations are executed is important.
In the above example, we have declared two functions, that is one() and two(), and now we are calling the two() function. The following output we will recieve.
Here in ouput you can see output is in sequential.
Concurrently - other codes are allowed to run parallelly even without waiting for the current code to finish
In the above code example, if we see the output of the code, we notice that after printing "Print one", "Print three" is printed out in our console before "Print two after 2 seconds" and this is because of the asynchronous execution of the code here in the code example the setTimeout() function waits for 2 seconds.
|1||Synchronous programming||Concurrent Execution|
|2||Blocking Nature||Non-Blocking Nature|
|3||Simple Control Flow||Event-driven Model|