![图片[1]-js中可选的回调函数-uusu优素-乐高,模型,3d打印,编程](https://uusu.cn/wp-content/uploads/2025/01/1635477850120570.png)
1、then的回调函数不是严格要求必写的。如果不写,promise也会用上一个返回的最终值来传递。
doSomething().then().then(function(result){
console.log('gotaresult',result);
});
//输出结果是:
//
//gotaresult42
2、如果当前的then没有传输回调函数,该函数将直接使用前一个promise返回的最终值来解决下一个promise。
if(!handler.onResolved){
handler.resolve(value);
return;
}原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END

















































暂无评论内容