Last active
October 13, 2019 14:39
-
-
Save XHMM/91fbe704eaa1ac9df994b447ce015cc0 to your computer and use it in GitHub Desktop.
write output of the code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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