Welcome to Shaun Luttin's public notebook. It contains rough, practical notes. The guiding idea is that, despite what marketing tells us, there are no experts at anything. Sharing our half-baked ideas helps everyone. We're all just muddling thru. Find out more about our work at bigfont.ca.

JavaScript method syntax and chaining Promises

Tags: javascript, promise

Live demo

promise

  .then((bar) => { return do_this(bar); }) /* 1: YES */

  .then(function(bar) { do_this(bar); }) /* 2: NO */

  .then(function (bar) { return do_this(bar); }) /* 3: YES */

  .then((bar) => { do_this(bar); }) /* 4: NO */

  .then(do_this) /* 5: YES */

  .then((bar) => do_this(bar)) /* 6: YES */

  .then((bar) => { do_this(bar); }); /* 7 */