What’s the difference between returning value or Promise.resolve from then()

What is the difference between:

new Promise(function(res, rej) {
    res("aaa");
  })
  .then(function(result) {
    return "bbb";
  })
  .then(function(result) {
    console.log(result);
  });

and this:

new Promise(function(res, rej) {
    res("aaa");
  })
  .then(function(result) {
    return Promise.resolve("bbb");
  })
  .then(function(result) {
    console.log(result);
  });

I’m asking as I’m getting different behaviour Using Angular and $http service with chaining .then(). A bit too much code hence first the example above.

6 Answers
6

Leave a Comment