Object.prototype.toString.call(Uint8Array.prototype) throws a TypeError
allen at wirfs-brock.com
Fri Aug 29 13:58:36 PDT 2014
On Aug 29, 2014, at 12:10 PM, John-David Dalton wrote:
> JS libs/frameworks (jQuery, Dojo, Lo-Dash, Ember, Angular, ...) have settled on using Object.prototype.toString.call as a way to determine the kind of a value and don't expect that to throw.
> This is edge case but it seems like an unnecessary gotcha to throw at devs.
We've explicitly designed the ES6 O.p.toString to preserve the [[Class]] type branding that was proved by prior editions but also decided to explicitly not support any new primitive [[Class]]-like brand values. Going forward it isn't a reliable way to type check or brand new built-in or programmer defined "types".
I will fix the handful of standard @@toStringTag getters so they don't throw. But I can't really really do anything about user written @@toStringTag getter that throw or for that matter objects that use Proxies to throw.
So, unless you wan to argue for eating exceptions in O.P.toStringm, that possibility will remain but is likely the reflection of a bug or malicious code. Presumablly, such problems can be diagnosed via a debugger
More information about the es-discuss