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

to delete #36236

Closed
cojack opened this issue Nov 23, 2020 · 1 comment
Closed

to delete #36236

cojack opened this issue Nov 23, 2020 · 1 comment

Comments

@cojack
Copy link

cojack commented Nov 23, 2020

delete this please

@cojack cojack changed the title return vs assigment and return to delete Nov 23, 2020
@aduh95
Copy link
Contributor

aduh95 commented Nov 23, 2020

This is not Node.js specific, it's just how JavaScript works. FYI, if you add an await in your return statement:

async function foo() {
    throw new Error('Foo');
}

async function bar() {
    try {
        return await foo();
    } catch (e) {
        return 2;
    }
}

(async () => {
    const d = await bar();
    console.log(d);
})();

@aduh95 aduh95 closed this as completed Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants