Reputation: 334
How does JavaScript execute Promises async when JS is single threaded? I know how to use Promises, but it is still unclear to me how it works behind the scene.
Upvotes: 3
Views: 842
Reputation: 77956
Promises are just a callback queue assigned to a lookup. Once you resolve the promise, it iterates over all callbacks which have been assigned via then
or done
.
Upvotes: 2