2017-08-26 5 views

Répondre

3

De l'Documentation

The following syntax with the new operator will throw a TypeError:

var sym = new Symbol(); // TypeError

This prevents authors from creating an explicit Symbol wrapper object instead of a new symbol value and might be surprising as creating explicit wrapper objects around primitive data types is generally possible (for example, new Boolean, new String and new Number).

Il suffit d'utiliser Symbol en fonction

var symbol = Symbol(4); 
 

 
console.log(typeof symbol); // outputs 'symbol'

+0

Merci beaucoup @Suren, ça marche :) Jamais pensé à la documentation officielle ... – Dev