JS: Promise .prototype .then

By Xah Lee. Date: .

Promise .prototype .then

syntax:

promise_object.then(f1,f2)

f1 and f2 are both functions of 1 parameter.

f1 and f2 are optional.

the then-method sets up handler functions to call on promise_object state. f1 or f2 is called as soon as the promise is settled.

The then-method returns a new promise object. (so it can be chained)

Throwing inside f1 or f2 in promise_object.then(f2,f2) rejects the promise created by the then-method.