Typing Errors
Caught errors are unknown. Narrow with instanceof before use.
Example
try { JSON.parse("{"); } catch (e) {
if (e instanceof Error) console.log(e.name);
else console.log("unknown error");
}Result
SyntaxError
Exercise
Check Error.
e Error
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.