37 lines
712 B
Plaintext
37 lines
712 B
Plaintext
``++Symbol++`` is a primitive type introduced in ECMAScript2015. Its instances are mainly used as unique property keys.
|
|
|
|
An instance can only be created by using ``++Symbol++`` as a function. Using ``++Symbol++`` with the ``++new++`` operator will raise a ``++TypeError++``.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
const sym = new Symbol("foo"); // Noncompliant
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
const sym = Symbol("foo");
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|