This is one that’s been bugging me for years, but today something happened that finally made me decide to rant about it. ECMAScript’s
throw statement has it’s uses in
try... catch... finally blocks but it’s also used often outside, on its own, to halt script execution. The most notable example I can think of is on line 480 of Crockford’s json2.js:
// If the text is not JSON parseable, then a SyntaxError is thrown. throw new SyntaxError('JSON.parse');
Now, most browsers don’t have a problem with this and not just because they support native
The strange thing is that Internet Explorer will behave properly if the throw statement is throwing an
Error object. The error message will be the one supplied to the
Error constructor. So why doesn't this happen for
ReferenceError? Other browsers will display the error message even if you just
throw a string.
When Internet Explorer 9 hit beta, I decided to report this as an "interoperability issue". The Internet Explorer team are always banging on about how they're trying to make Internet Explorer work like other browsers by following standards and non-standard, but popular, implementations of various functionality. I thought to myself, "How hard can it be to fix this?". Surely, there will be one code path for if you throw an
Error object and another code path for everything else, so the first one could be quite easily expanded to accommodate everything else instead? As it happens, today my issue was changed to "Resolved", then "Closed" as "By design".
So there you have it, straight from the horse's mouth; Internet Explorer hinders your development in as many ways as possible "by design".
For some reason, the link to the bug report is telling people they don't have the required permissions to view. It is set to public, however, so I'm not sure what's going on there (perhaps they want to hide their shame!).