Can someone explain why this prints in reverse order?
Code:
when('test')
.then(function() {console.log('should be first');})
.then(console.log('should be second'));
Output:
should be second
should be first
PS: I am using when.js version: when@3.4.3
You're immediately executing the second console.log
, and passing the return value to then
. You need to pass functions to then
.
You've effectively done this:
var x = console.log('should be second')
when('test')
.then(function () { console.log('should be first'); })
.then(x);