Allowing configurability of the value of a built-in object's @@toStringTag
property has the (likely undesirable) side effect of making calls to
Object.prototype.toString.call(o) unreliable.

Illustrated here: https://twitter.com/caitp88/status/525700685942509569

Repeated here for the purpose of discussion:

  Object.prototype.toString.call(new Map());
  "[object Map]"
  Object.defineProperty(Map.prototype, Symbol.toStringTag, { value: "Fish"
});
  // ...
  Object.prototype.toString.call(new Map());
  "[object Fish]"

While this won't break existing code (see:
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring),
there should be consistency across built-ins. I propose we adopt as a rule
that the @@toStringTag for all _built-ins_ is always defined as:

{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }


Rick
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to