Object.prototype.toString.call(Uint8Array.prototype) throws a TypeError

John-David Dalton john.david.dalton at gmail.com
Fri Aug 29 12:10:57 PDT 2014


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.

- JDD


On Fri, Aug 29, 2014 at 11:57 AM, Jason Orendorff <jason.orendorff at gmail.com
> wrote:

> On Fri, Aug 29, 2014 at 5:09 AM, Andrea Giammarchi
> <andrea.giammarchi at gmail.com> wrote:
> > Wouldn't that be inconsistent with `{}.toString.call(String.prototype)`
> and
> > all others ?
>
> It is inconsistent, but it's a change TC39 deliberately chose to take.
>
> It's a good change. The fact that Date.prototype is a real Date
> object, for example, has been a common source of bugs and general
> weirdness.
>
> -j
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140829/6d9e50bc/attachment.html>


More information about the es-discuss mailing list