diff options
| author | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-09-04 00:46:12 +0900 |
|---|---|---|
| committer | Masahiro FUJIMOTO <mfujimot@gmail.com> | 2021-09-04 00:46:12 +0900 |
| commit | fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f (patch) | |
| tree | 51b7edfc370236684a203f4e69ae67bb7d24b549 /files/fr/web/javascript/reference/global_objects/string/concat | |
| parent | 04ea4edc83cc12142ed151bbea2c65cffc8e76f6 (diff) | |
| parent | eeb07fe338cdc90092841d717919f46f9d9e3ff9 (diff) | |
| download | translated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.tar.gz translated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.tar.bz2 translated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.zip | |
Merge branch 'main' into 20210818-Glossary/Type
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/string/concat')
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/string/concat/index.html | 103 | ||||
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/string/concat/index.md | 76 |
2 files changed, 76 insertions, 103 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/string/concat/index.html b/files/fr/web/javascript/reference/global_objects/string/concat/index.html deleted file mode 100644 index 8958a7491f..0000000000 --- a/files/fr/web/javascript/reference/global_objects/string/concat/index.html +++ /dev/null @@ -1,103 +0,0 @@ ---- -title: String.prototype.concat() -slug: Web/JavaScript/Reference/Global_Objects/String/concat -tags: - - JavaScript - - Méthode - - Prototype - - Reference - - String -translation_of: Web/JavaScript/Reference/Global_Objects/String/concat -original_slug: Web/JavaScript/Reference/Objets_globaux/String/concat ---- -<div>{{JSRef}}</div> - -<p>La méthode <code><strong>concat()</strong></code> combine le texte de plusieurs chaînes avec la chaîne appelante et renvoie la nouvelle chaîne ainsi formée.</p> - -<div>{{EmbedInteractiveExample("pages/js/string-concat.html")}}</div> - -<h2 id="Syntaxe">Syntaxe</h2> - -<pre class="syntaxbox notranslate"><var>str</var>.concat(<var>string2</var>[, <var>string</var>3, ..., <var>stringN</var>])</pre> - -<h3 id="Paramètres">Paramètres</h3> - -<dl> - <dt><code>string2...string<em>N</em></code></dt> - <dd>Chaînes de caractères à concaténer ensemble.</dd> -</dl> - -<h3 id="Valeur_de_retour">Valeur de retour</h3> - -<p>Une nouvelle chaîne de caractères qui contient la concaténation des chaînes de caractères fournies.</p> - -<h2 id="Description">Description</h2> - -<p>La fonction <code>concat()</code> renvoie une nouvelle chaîne correspondant à la concaténation des différents arguments avec la chaîne courante. La chaîne courante est celle sur laquelle a été appelée la méthode <code>concat()</code>. Si les valeurs passées en arguments ne sont pas des chaînes de caractères, elles sont automatiquement converties en chaînes (grâce à leur méthode <code>toString()</code> avant la concaténation).</p> - -<h2 id="Exemples">Exemples</h2> - -<p>L'exemple suivant combine plusieurs chaînes afin d'en former une nouvelle.</p> - -<pre class="brush: js notranslate">var coucou = "Bonjour "; -console.log(coucou.concat("Tristan,", " bonne journée.")); - -/* Bonjour Tristan, bonne journée. */ - -var salutation = ['Bonjour', ' ', 'Alfred', ' ', '!']; -"".concat(...salutation); // "Bonjour Alfred !" - -"".concat({}); // [object Object] -"".concat([]); // "" -"".concat(null); // "null" -"".concat(true); // "true" -"".concat(4, 5); // "45" - -</pre> - -<h2 id="Performance">Performance</h2> - -<p>Il est fortement recommandé d'utiliser les {{jsxref("Opérateurs/Opérateurs_d_affectation", "opérateurs d'affectation", "", 1)}} (+, +=) plutôt que la méthode <code>concat()</code> pour des raisons de performance.</p> - -<h2 id="Spécifications">Spécifications</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">État</th> - <th scope="col">Commentaires</th> - </tr> - <tr> - <td>{{SpecName('ES3')}}</td> - <td>{{Spec2('ES3')}}</td> - <td>Définition initiale. Implémentée avec JavaScript 1.2.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.5.4.6', 'String.prototype.concat')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-string.prototype.concat', 'String.prototype.concat')}}</td> - <td>{{Spec2('ES6')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-string.prototype.concat', 'String.prototype.concat')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - -<p>{{Compat("javascript.builtins.String.concat")}}</p> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<ul> - <li>{{jsxref("Array.prototype.concat()")}}</li> - <li>{{jsxref("Opérateurs/Opérateurs_d_affectation", "Les opérateurs d'affectation", "", 1)}}</li> -</ul> diff --git a/files/fr/web/javascript/reference/global_objects/string/concat/index.md b/files/fr/web/javascript/reference/global_objects/string/concat/index.md new file mode 100644 index 0000000000..10583c89a1 --- /dev/null +++ b/files/fr/web/javascript/reference/global_objects/string/concat/index.md @@ -0,0 +1,76 @@ +--- +title: String.prototype.concat() +slug: Web/JavaScript/Reference/Global_Objects/String/concat +tags: + - JavaScript + - Méthode + - Prototype + - Reference + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/concat +original_slug: Web/JavaScript/Reference/Objets_globaux/String/concat +--- +{{JSRef}} + +La méthode **`concat()`** combine le texte de plusieurs chaînes avec la chaîne appelante et renvoie la nouvelle chaîne ainsi formée. + +{{EmbedInteractiveExample("pages/js/string-concat.html")}} + +## Syntaxe + + str.concat(string2[, string3, ..., stringN]) + +### Paramètres + +- `string2...stringN` + - : Chaînes de caractères à concaténer ensemble. + +### Valeur de retour + +Une nouvelle chaîne de caractères qui contient la concaténation des chaînes de caractères fournies. + +## Description + +La fonction `concat()` renvoie une nouvelle chaîne correspondant à la concaténation des différents arguments avec la chaîne courante. La chaîne courante est celle sur laquelle a été appelée la méthode `concat()`. Si les valeurs passées en arguments ne sont pas des chaînes de caractères, elles sont automatiquement converties en chaînes (grâce à leur méthode `toString()` avant la concaténation). + +## Exemples + +L'exemple suivant combine plusieurs chaînes afin d'en former une nouvelle. + +```js +var coucou = "Bonjour "; +console.log(coucou.concat("Tristan,", " bonne journée.")); + +/* Bonjour Tristan, bonne journée. */ + +var salutation = ['Bonjour', ' ', 'Alfred', ' ', '!']; +"".concat(...salutation); // "Bonjour Alfred !" + +"".concat({}); // [object Object] +"".concat([]); // "" +"".concat(null); // "null" +"".concat(true); // "true" +"".concat(4, 5); // "45" +``` + +## Performance + +Il est fortement recommandé d'utiliser les {{jsxref("Opérateurs/Opérateurs_d_affectation", "opérateurs d'affectation", "", 1)}} (+, +=) plutôt que la méthode `concat()` pour des raisons de performance. + +## Spécifications + +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------- | ----------------------------------------------------- | +| {{SpecName('ES3')}} | {{Spec2('ES3')}} | Définition initiale. Implémentée avec JavaScript 1.2. | +| {{SpecName('ES5.1', '#sec-15.5.4.6', 'String.prototype.concat')}} | {{Spec2('ES5.1')}} | | +| {{SpecName('ES6', '#sec-string.prototype.concat', 'String.prototype.concat')}} | {{Spec2('ES6')}} | | +| {{SpecName('ESDraft', '#sec-string.prototype.concat', 'String.prototype.concat')}} | {{Spec2('ESDraft')}} | | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.String.concat")}} + +## Voir aussi + +- {{jsxref("Array.prototype.concat()")}} +- {{jsxref("Opérateurs/Opérateurs_d_affectation", "Les opérateurs d'affectation", "", 1)}} |
