Default @@toStringTag for user classes

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Mon Dec 1 23:46:20 PST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141201/fdfbc08b/attachment.html>


More information about the es-discuss mailing list