Default @@toStringTag for user classes

Michał Wadas michalwadas at gmail.com
Tue Dec 2 00:04:45 PST 2014


It probably would be backward incompatible change. Too much code depends on
[Object Object].
2 gru 2014 08:46 "Dmitry Soshnikov" <dmitry.soshnikov at gmail.com> napisał(a):

> Hi,
>
> Probably worth providing a default implementation of the `@@toStringTag`
> when evaluating a class [1]. In this case users will be able to do:
>
> ```
> class Point { ... }
>
> var p = new Point(1, 2);
> console.log(p); // "[object Point]"
> ```
>
> The default implementation will be just (if the `className` is defined of
> course):
>
> ```
> proto[@@toStringTag] = function() {
>   return className;
> };
> ```
>
> [1]
> https://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-classdefinitionevaluation
>
> Dmitry
>
> _______________________________________________
> 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/20141202/83d06bee/attachment.html>


More information about the es-discuss mailing list