gpt4 book ai didi

javascript - 阐明 Javascript 回调流程

转载 作者:行者123 更新时间:2023-12-03 03:10:47 26 4
gpt4 key购买 nike

我有一些带有多个回调的不同代码路径。

this.confirmJWT(
function() {
this.confirmVendorCode(
function() {
this.downloadFile(FORECAST);
}.bind(this)
);
}.bind(this)
);

我知道人们称此回调 hell (实际上刚刚找到 http://callbackhell.com/ ),但我正在寻找编写此浏览器代码的首选方法。

最佳答案

使用 ES6 编写它会使其更短,但可能不那么可读。

this.confirmJWT(() => this.confirmVendorCode(() => this.downloadFile(FORECAST)));

关于javascript - 阐明 Javascript 回调流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46961641/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com