a Promise represents an operation that hasn`t completed yet, but is expected in the future
Promise
is a global function
the constructor
instantiating it without params throws
expects a function as parameter
simplest promises
resolve a promise by calling the resolve
function given as first parameter
the resolve
function can return a value, that is consumed by the promise.then()
callback
rejecting a promise is done by calling the callback given as 2nd parameter
an asynchronous promise
can resolve later, also by calling the first callback
reject it at some later point in time, calling the 2nd callback
Links
A well understandable description of the states a promise can be in.
Related Katas
Promise
Difficulty Level
BEGINNER
First Published
9 October 2015
Stats
8 tests to solve