Log in to customize your experience and get involved.
I'll give an example.
Since it is asynchronous, it calls the get_value_from_DB method but it does not wait till it finishes.
It knows that DB operations rely on network and I/O; which are slow. And hence, it lets the execution of your program move ahead before get_value_from_DB could return a value.
Hence, it prints undefined.
The disadvantage is that you have to learn how to complete your tasks despite this async behavior.
For example, how do I write the result (be it 42 or -1) of get_value_from_DB to the console?
We’d love for you to be a part of this community.