Hacker News new | ask | show | jobs
by rmrfrmrf 3213 days ago
`throw` can throw anything. By convention, it throws Error objects.
2 comments

Sure, but "exception" is the programming term for that kind of behaviour. Saying "JavaScript has exceptions" doesn't imply that JavaScript has a global builtin object named `Exception` any more than saying "JavaScript has loops" implies that there's a global builtin object named `Loop` or `For`.
"throw" takes the value to throw as an exception. An exception is an event which can be handled with "catch". [1] The standard refers to predefined errors such as TypeError as "exceptions".

[1] http://www.ecma-international.org/ecma-262/6.0/#sec-try-stat...