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?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
For further actions, you may consider blocking this person and/or reporting abuse