From 39f2114f9797eb51994966c6bb8ff1814c9a4da8 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 12:36:08 +0100 Subject: unslug fr: move --- .../global_objects/string/tostring/index.html | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 files/fr/web/javascript/reference/global_objects/string/tostring/index.html (limited to 'files/fr/web/javascript/reference/global_objects/string/tostring') diff --git a/files/fr/web/javascript/reference/global_objects/string/tostring/index.html b/files/fr/web/javascript/reference/global_objects/string/tostring/index.html new file mode 100644 index 0000000000..ef3618a8b5 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/string/tostring/index.html @@ -0,0 +1,82 @@ +--- +title: String.prototype.toString() +slug: Web/JavaScript/Reference/Objets_globaux/String/toString +tags: + - JavaScript + - Méthode + - Prototype + - Reference + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/toString +--- +
{{JSRef}}
+ +

La méthode toString() renvoie une chaine de caractères représentant l'objet renseigné.

+ + + +
{{EmbedInteractiveExample("pages/js/string-tostring.html")}}
+ +

Syntaxe

+ +
str.toString()
+ +

Valeur de retour

+ +

Une chaîne de caractères représentant la chaîne appelante.

+ +

Description

+ +

L'objet {{jsxref("String")}} surcharge la méthode toString() de l'objet {{jsxref("Object")}} ; il n'hérite pas de {{jsxref("Object.toString","Object.prototype.toString()")}}. Pour Les objets String, la méthode toString() renvoie une chaine de caractères représentant l'objet, et est similaire à la méthode {{jsxref("String.prototype.valueOf()")}}.

+ +

Exemples

+ +

L'exemple suivant affiche la valeur textuelle d'un objet  {{jsxref("String")}} :

+ +
var x = new String("coucou monde");
+console.log(x.toString()); // affiche "coucou monde"
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('ES3')}}{{Spec2('ES3')}}Définition initiale. Implémentée avec JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.5.4.2', 'String.prototype.toString')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-string.prototype.tostring', 'String.prototype.toString')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-string.prototype.tostring', 'String.prototype.toString')}}{{Spec2('ESDraft')}} 
+ +

Compatibilité des navigateurs

+ + + +

{{Compat("javascript.builtins.String.toString")}}

+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf