Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

译文的代码有漏 #6178

Closed
raylhx opened this issue Jul 22, 2019 · 1 comment
Closed

译文的代码有漏 #6178

raylhx opened this issue Jul 22, 2019 · 1 comment

Comments

@raylhx
Copy link

raylhx commented Jul 22, 2019

原文地址:https://blog.sessionstack.com/how-javascript-works-event-loop-and-the-rise-of-async-programming-5-ways-to-better-coding-with-2f077c4438b5

对应翻译文章:JavaScript 是如何工作的: 事件循环和异步编程的崛起 + 5个如何更好的使用 async/await 编码的技巧

遗漏的区域:
定位到——第五点:5 个编写可维护的、健壮的异步代码的技巧的第二小点#错误处理#
原文中是有优化前的代码以及优化后的代码,译文中很明显是缺少优化前的代码,如下:

function loadData() {
    try { // Catches synchronous errors.
        getJSON().then(function(response) {
            var parsed = JSON.parse(response);
            console.log(parsed);
        }).catch(function(e) { // Catches asynchronous errors
            console.log(e); 
        });
    } catch(e) {
        console.log(e);
    }
}
@sunui
Copy link
Contributor

sunui commented Jul 23, 2019

已修复,非常感谢!🙏

@sunui sunui closed this as completed Jul 23, 2019
@leviding leviding removed their assignment Jul 23, 2019
pingren pushed a commit to pingren/gold-miner that referenced this issue Jul 31, 2019
xitu#6178 代码遗漏更正
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants