3 ms·
> there’s no concept of Exception in JS Sure there is. What else does the `throw` statement do, if not throw an exception?
by amptorn 9y ago
> there’s no concept of Exception in JS
Sure there is. What else does the `throw` statement do, if not throw an exception?
- rmrfrmrf 9y ago`throw` can throw anything. By convention, it throws Error objects.
- lobster_johnson 9y ago"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-statement http://www.ecma-international.org/ecma-262/6.0/#sec-try-stat...
- amptorn 9y agoSure, 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`.