http://jsbin.com/tuqukakawo/1/edit?js,console,output
#1
doSomething().then(function () {
return doSomethingElse();
}).then(finalHandler);
答案:
doSomething
|-----------------|
doSomethingElse(undefined)
|------------------|
finalHandler(resultOfDoSomethingElse)
|------------------|
#2
doSomething().then(function () {
doSomethingElse();
}).then(finalHandler);
答案:
doSomething
|-----------------|
doSomethingElse(undefined)
|------------------|
finalHandler(undefined)
|------------------|
#3
doSomething().then(doSomethingElse())
.then(finalHandler);
答案
doSomething
|-----------------|
doSomethingElse(undefined)
|---------------------------------|
finalHandler(resultOfDoSomething)
|------------------|
#4
doSomething().then(doSomethingElse)
.then(finalHandler);
答案
doSomething
|-----------------|
doSomethingElse(resultOfDoSomething)
|------------------|
finalHandler(resultOfDoSomethingElse)
|------------------|