In nodejs or javascript code using the q library https://github.com/kriskowal/q will assigning the result of one function invoked by .then() to a function scope variable and using it in the next .then() invokation result in errors.
var q = require('q');
function example() {
var result1;
return q()
.then(function() {
result1 = 1;
return 2;
})
.then(function(two) {
return result1 + two;
});
}