Considering all job1, job2, job3 and job4
return promises, what is the difference between apart from nuances of code readability. What does test() return in either case? Let's say doSomething() is a heavy async operation, should chaining be used or first method be used?
function test() {
return job().then(function() {
return job2().then(function() {
return job3().then(function() {
return job4().then(function() {
doSomething();
});
});
});
});
}
and
function test() {
return job()
.then(function() {
return job2();
})
.then(function() {
return job3();
})
.then(function() {
return job4();
})
.then(function() {
doSomething();
});
}