Return statement in promises

I'm writing a simple controller for a GET request in node.js that uses promises. The code works, but I'm not 100% sure why. I have a getStoriesHelper function that returns a promise, and after I get the result, it does return res.json(listOfStories);. This works, but I was under the impression that returns only breaks out of a single function scope (so I assume it should only break out of the anonymous function scope), and just wondering why it would break out of the getStories function as well?

//for instance, the return statement only breaks out of the anonymous function and not from dummy()
function dummy() {
    _.map([1, 2, 3], function(element) {
        return element * 2;
    }
}

//node.js controller
exports.getStories = function(req, res) {
  var studentId = req.params.studentId;

  User.findOne({role: 'student', _id: studentId}).exec()
    .then(function(student) {
      var isNursery = student.status === 'attending class' && user.bookLevel === 'nursery';

      getStoriesHelper(student, isNursery).then(function(listOfStories) {
        //shouldn't return only break out of this inner function scope
        return res.json(listOfStories)
      });
    });
};

//dummy async code
function getStoriesHelper() {
  var deferred = Q.defer();
  setTimeout(function() {
    deferred.resolve(123)
  }, 3000);
  return deferred.promise;
}

Your code works because

  1. findOne and getStoriesHelper are asynchronous and res still is in scope within them.

  2. The statement return res.json(listOfStories) does two things. it writes the response to the output stream as well as returns the value returned by res.json() which is never used, so in fact it won't harm if you do not return, the function is about to return already.

  3. getStories function is already ended the moment you called an async function so don't think that inner return has any effect outside that anonymous function.