Hacker News new | ask | show | jobs
by amptorn 3211 days ago
> there’s no concept of Exception in JS

Sure there is. What else does the `throw` statement do, if not throw an exception?

1 comments

`throw` can throw anything. By convention, it throws Error objects.
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...