问:下面四个使用 promise 的语句之间的不同点在哪儿?
doSomething().then(function () {
return doSomethingElse();
});
doSomethin().then(function () {
doSomethingElse();
});
doSomething().then(doSomethingElse());
doSomething().then(doSomethingElse);
function doSomething(){ return Promise.resolve(1); }
function doSomethingElse(){ return Promise.resolve(2); }
doSomething().then(function () { return doSomethingElse(); }).then(function (result) { console.log(result) });
doSomething().then(function () { doSomethingElse(); }).then(function (result) { console.log(result) });
doSomething().then(doSomethingElse()).then(function (result) { console.log(result) });
doSomething().then(doSomethingElse).then(function (result) { console.log(result) }); 大家测测比较好~