Tsallaka zuwa abun ciki
Justice Tech School

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

What type is e in catch?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.