You are viewing a single comment's thread from:

RE: Javascript Promise Chaining

in #javascript7 years ago

Promises are awesome! One of the main advantages over callbacks is the ability to chain promises. So you could also do something like this - I think it's more readable than nesting Promises:

add(2, 3)
  .then(response => addMore(response, 10))
  .then(response => console.log(response))

Or, if you like the bind variant:

add(2, 3)
  .then(addMore.bind(null, 10))
  .then(response => console.log(response))

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60385.82
ETH 2321.90
USDT 1.00
SBD 2.51