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/repeat/index.html | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 files/fr/web/javascript/reference/global_objects/string/repeat/index.html (limited to 'files/fr/web/javascript/reference/global_objects/string/repeat') diff --git a/files/fr/web/javascript/reference/global_objects/string/repeat/index.html b/files/fr/web/javascript/reference/global_objects/string/repeat/index.html new file mode 100644 index 0000000000..3245288bd9 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/string/repeat/index.html @@ -0,0 +1,87 @@ +--- +title: String.prototype.repeat() +slug: Web/JavaScript/Reference/Objets_globaux/String/repeat +tags: + - ECMAScript 2015 + - JavaScript + - Méthode + - Prototype + - Reference + - String + - polyfill +translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat +--- +
{{JSRef}}
+ +

La méthode repeat() construit et renvoie une nouvelle chaine de caractères qui contient le nombre de copie demandée de la chaine de caractères sur laquelle la méthode a été appelée, concaténées les unes aux autres.

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

Syntaxe

+ +
str.repeat(compte)
+ +

Paramètres

+ +
+
compte
+
Un nombre entier entre 0 and +∞ : [ 0, +∞[, indiquant le nombre de fois que la chaine de caractères doit être repétée dans la nouvelle chaine de caractères.
+
+ +

Valeur de retour

+ +

Une nouvelle chaîne de caractères composée du nombre indiqué de copies de la chaîne appelante.

+ +

Exceptions

+ + + +
+
{{jsxref("RangeError")}}
+
La compteur doit être positif et inférieur à l'infini.
+
+ +

Exemples

+ +
"abc".repeat(-1)     // RangeError
+"abc".repeat(0)      // ""
+"abc".repeat(1)      // "abc"
+"abc".repeat(2)      // "abcabc"
+"abc".repeat(3.5)    // "abcabcabc" (le compteur est converti en un nombre entier)
+"abc".repeat(1/0)    // RangeError
+
+({toString : () => "abc", repeat : String.prototype.repeat}).repeat(2)
+// "abcabc" (repeat() est une méthode générique)
+ +

Spécifications

+ + + + + + + + + + + + + + + + + + + +
SpécificationÉtatCommentaire
{{SpecName('ES2015', '#sec-string.prototype.repeat', 'String.prototype.repeat')}}{{Spec2('ES2015')}}Première définition.
{{SpecName('ESDraft', '#sec-string.prototype.repeat', 'String.prototype.repeat')}}{{Spec2('ESDraft')}}
+ +

Compatibilité des navigateurs

+ + + +

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

-- cgit v1.2.3-54-g00ecf