Great article, but one question how’s this asynchronous ?
According to MDN: Asynchronous
, asynchronous code may refer to multiple related tasks happening without waiting for each other to complete.
In our case, if the code was not asynchronous, the setTimeout call whould have blocked the execution of the program until it was completed printing "Two" at the console.
But this is not the case. The program continues executing, printing "three" and, after that, the callback of the setTimeout is called, printing "Two" at the end.
Hmm, it seemed to me just like synchronous execution with a bit of instructions reordering.
The environment (browser, node etc) is the one that arranges the events resulting in asynchronous execution (the use o callbacks, promises, ajax calls etc)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.