Skip to content

Instantly share code, notes, and snippets.

@XHMM
Last active October 13, 2019 14:39
Show Gist options
  • Save XHMM/91fbe704eaa1ac9df994b447ce015cc0 to your computer and use it in GitHub Desktop.
Save XHMM/91fbe704eaa1ac9df994b447ce015cc0 to your computer and use it in GitHub Desktop.
write output of the code
async function aa() {
try {
return Promise.reject('return reject')
} catch (e) {
console.log(e)
}
}
aa().then(val => {
console.log(val);
}).catch(err => {
console.log(err);
});
(async () => {
try {
const val = await aa();
console.log(val);
} catch (e) {
console.log(e)
}
})();
async function bb() {
try {
return new Error('return error')
} catch (e) {
console.log(e)
}
}
bb().then(val => {
console.log(val);
}).catch(err => {
console.log(err);
});
(async () => {
try {
const val = await bb();
console.log(val);
} catch (e) {
console.log(e)
}
})();
async function cc() {
try {
throw new Error('throw error')
} catch (e) {
console.log(e)
}
}
cc().then(val => {
console.log(val);
}).catch(err => {
console.log(err);
});
(async () => {
try {
const val = await cc();
console.log(val);
} catch (e) {
console.log(e)
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment