跳到主要内容
CNode

一道题 Promise

分享
CcoDelesLie发布于 11 年前最后回复 10 年前
1367070

问:下面四个使用 promise 的语句之间的不同点在哪儿?

doSomething().then(function () {
    return doSomethingElse();
});

doSomethin().then(function () {
    doSomethingElse();
});

doSomething().then(doSomethingElse());

doSomething().then(doSomethingElse);
查看回复

回复 (13)

W
wwhgtt#1310 年前

不错 学习了

C
coDelesLie#1111 年前

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) }); 大家测测比较好~

R
reverland#911 年前

ydkjs promise那里讲得也不错,可以对照的看。不过依然是踩了坑才能想起来

T
Tonyce#811 年前

mark

G
gjc9620#711 年前

好文特别是 接受两个参数的那里 解决了我多年的问题啊 赞赞

C
caiyongmin#611 年前

mark住

S
sharkrice#511 年前

不知道有没有翻译,勉强看懂一些 自豪地采用 CNodeJS ionic

Q
qianjiahao#311 年前

你真的了解Promise吗? 这篇博文让人受益匪浅~

A
alsotang#211 年前

题目不错嘿嘿

K
klamtlne#111 年前

参与回复

登录后即可参与回复。登录