I have seen the following two codes on the internet and I can't really understand how they are being parsed and executed. BTW I am new to ES6.
return getUsername()
.then(function (username) {
return getUser(username);
})
.then(function (user) {
});
Is it correct to interpret the above code as:
return getUsername().then(function(username){return getUser(username);}).then(function (user){});
Or Does it have some different meaning in the ES6?
Similarly in the following:
new Q(value)
.then(function(/*Success handler*/){}, function(/*Failure handler*/){})
Should it be interpreted as:
new Q(value).then(function(/*Success handler*/){},function(/*Failure handler*/){})