--- title: Symbol.prototype slug: conflicting/Web/JavaScript/Reference/Global_Objects/Symbol tags: - ECMAScript6 - JavaScript - Propriété - Reference - Symbol translation_of: Web/JavaScript/Reference/Global_Objects/Symbol translation_of_original: Web/JavaScript/Reference/Global_Objects/Symbol/prototype original_slug: Web/JavaScript/Reference/Objets_globaux/Symbol/prototype ---
{{JSRef}}

La propriété Symbol.prototype représente le prototype du constructeur {{jsxref("Symbol")}}.

{{EmbedInteractiveExample("pages/js/symbol-prototype.html")}}

Description

Les instances de {{jsxref("Symbol")}} héritent toutes de {{jsxref("Symbol.prototype")}}. Ce prototype du constructeur peut être utilisé afin d'ajouter des propriétés et/ou des méthodes pour chaque instance de Symbol via la chaîne de prototypes.

{{js_property_attributes(0,0,0)}}

Propriétés

Symbol.prototype.constructor
Cette propriété correspond à la fonction qui a crée l'instance du prototype. Par défaut, c'est la fonction {{jsxref("Symbol")}} qui est renvoyée.
{{jsxref("Symbol.prototype.description")}}
Une chaîne de caractères en lecture seule qui contient la description du symbole.

Méthodes

{{jsxref("Symbol.prototype.toSource()")}} {{Non-standard_inline}}
Cette méthode renvoie une chaîne de caractères contenant la source de l'objet {{jsxref("Objets_globaux/Symbol", "Symbol")}}. Cette méthode surcharge la méthode {{jsxref("Object.prototype.toSource()")}}.
{{jsxref("Symbol.prototype.toString()")}}
Cette méthode renvoie une chaîne de caractères contenant la description du symbole. Cette méthode surcharge la méthode {{jsxref("Object.prototype.toString()")}}.
{{jsxref("Symbol.prototype.valueOf()")}}
Cette méthode renvoie la valeur primitive de l'objet {{jsxref("Symbol")}}. Cette méthode surcharge la méthode {{jsxref("Object.prototype.valueOf()")}}.
{{jsxref("Symbol.prototype.@@toPrimitive()", "Symbol.prototype[@@toPrimitive]")}}
Renvoie la valeur primitive de l'objet {{jsxref("Symbol")}}.

Spécifications

Spécification État Commentaires
{{SpecName('ES6', '#sec-symbol.prototype', 'Symbol.prototype')}} {{Spec2('ES6')}} Définition initiale.
{{SpecName('ESDraft', '#sec-symbol.prototype', 'Symbol.prototype')}} {{Spec2('ESDraft')}}  

Compatibilité des navigateurs

{{Compat("javascript.builtins.Symbol.prototype")}}