|Author:||Mr. Alexander Hudson|
|Published:||3 June 2014|
|PDF File Size:||28.38 Mb|
|ePub File Size:||18.2 Mb|
|Uploader:||Mr. Alexander Hudson|
In other words, the function defined in the closure 'remembers' the environment in which it was created in.
Callbacks, Promises, and Async
With Promises, we can defer execution of a code block until an async request is completed. Your mom promises you that she'll get you a new phone next week. Your mom can either really buy you a brand new phone, or stand you up and withhold the phone if she is not happy: That is a promise.
A promise has 3 states.
Let's log a message before and after we call the promise. Hey friend, I have a new black Samsung phone.