Why ES6 introduced classes yet `Symbol` not to be used with `new`?
andrea.giammarchi at gmail.com
Mon Aug 15 08:27:19 UTC 2016
FWIW, if `Object(Symbol()) instanceof Symbol` is true, and it is, we can
say `Symbol` is just an anomaly in the specs because it acts like other
primitive constructors but it throws if used as `new Symbol()`.
Developers that would've written `new Symbol` are the same that write `new
Boolean` or `new Number` and `new String`.
If these people don't put minimal effort to better learn/use the
programming language I wonder why the rest of the entire community should
be penalised with "quirks" like `Symbol` is.
Throw at everything and then, or don't ... and keep it consistent in both
good or bad expectations.
I know it's too late for `Symbol` but I hope there won't be other
inconsistent primitives/classes added to the lang in the future.
On Mon, Aug 15, 2016 at 12:15 AM, Domenic Denicola <d at domenic.me> wrote:
> Symbol is not a class.
> *From:* es-discuss [mailto:es-discuss-bounces at mozilla.org] *On Behalf Of *
> *Sent:* Sunday, August 14, 2016 18:31
> *To:* es-discuss <es-discuss at mozilla.org>
> *Subject:* Why ES6 introduced classes yet `Symbol` not to be used with
> It seems like `new Symbol()` would be inline with the introduction of
> classes. Why was it chosen not to be constructible? Seems like it would
> make sense to throw an error on `Symbol()` but not `new Symbol()`. Was it
> to save three characters of typing?
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss