Skip to content

re: Modern JavaScript, 10 things you should be using, starting today VIEW POST

re: Can you return the items variable from outside the try{} block? Or would it be scoped inside the try block.

Yes you can, but if you return any value from a async function, the the promise that function returns will resolve, successfully.even if in the catch block of a try/catch block. This behavior can be vary useful. If you want the promise to throw an error you need to call

throw expression

Okay, are you saying that a try catch block is not even necessary? Because the results of the error will get shoved into whatever is returned by the async function either way?

code of conduct - report abuse