aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/string/trim
diff options
context:
space:
mode:
authorMasahiro FUJIMOTO <mfujimot@gmail.com>2021-09-04 00:46:12 +0900
committerMasahiro FUJIMOTO <mfujimot@gmail.com>2021-09-04 00:46:12 +0900
commitfe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f (patch)
tree51b7edfc370236684a203f4e69ae67bb7d24b549 /files/fr/web/javascript/reference/global_objects/string/trim
parent04ea4edc83cc12142ed151bbea2c65cffc8e76f6 (diff)
parenteeb07fe338cdc90092841d717919f46f9d9e3ff9 (diff)
downloadtranslated-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/trim')
-rw-r--r--files/fr/web/javascript/reference/global_objects/string/trim/index.html93
-rw-r--r--files/fr/web/javascript/reference/global_objects/string/trim/index.md74
2 files changed, 74 insertions, 93 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/string/trim/index.html b/files/fr/web/javascript/reference/global_objects/string/trim/index.html
deleted file mode 100644
index 24146f8e6f..0000000000
--- a/files/fr/web/javascript/reference/global_objects/string/trim/index.html
+++ /dev/null
@@ -1,93 +0,0 @@
----
-title: String.prototype.trim()
-slug: Web/JavaScript/Reference/Global_Objects/String/Trim
-tags:
- - ECMAScript 2015
- - JavaScript
- - Méthode
- - Prototype
- - Reference
- - String
- - polyfill
-translation_of: Web/JavaScript/Reference/Global_Objects/String/Trim
-original_slug: Web/JavaScript/Reference/Objets_globaux/String/trim
----
-<div>{{JSRef}}</div>
-
-<p>La méthode <strong><code>trim()</code></strong> permet de retirer les blancs en début et fin de chaîne. Les blancs considérés sont les caractères d'espacement (espace, tabulation, espace insécable, etc.) ainsi que les caractères de fin de ligne (LF, CR, etc.).</p>
-
-<div>{{EmbedInteractiveExample("pages/js/string-trim.html")}}</div>
-
-<h2 id="Syntaxe">Syntaxe</h2>
-
-<pre class="syntaxbox"><var>str</var>.trim()</pre>
-
-<h3 id="Valeur_de_retour">Valeur de retour</h3>
-
-<p>Une nouvelle chaîne de caractères dérivant de la chaîne appelante pour laquelle les blancs ont été retirés aux deux extrémités de la chaîne.</p>
-
-<h2 id="Description">Description</h2>
-
-<p>La méthode <code>trim()</code> renvoie la chaîne sans blanc au début et à la fin. La méthode <code>trim()</code> n'affecte pas la valeur de la chaîne courante.</p>
-
-<h2 id="Exemples">Exemples</h2>
-
-<p>L'exemple qui suit affiche la chaîne <code>'toto'</code> :</p>
-
-<pre class="brush: js">var chaîneOriginale = ' toto ';
-console.log(chaîneOriginale.trim()); // 'toto'
-
-// Un autre exemple de .trim() qui enlève les espaces juste d'un côté
-
-var chaîneOriginale = 'toto ';
-console.log(chaîneOriginale.trim()); // 'toto'
-</pre>
-
-<h2 id="Prothèse_d'émulation_(polyfill)">Prothèse d'émulation (<em>polyfill</em>)</h2>
-
-<p>Si l'environnement utilisé ne possède pas cette méthode, il est possible de l'émuler avec le fragment de code suivant :</p>
-
-<pre class="brush: js">if (!String.prototype.trim) {
-  String.prototype.trim = function () {
- return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
-  };
-}
-</pre>
-
-<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('ES5.1', '#sec-15.5.4.20', 'String.prototype.trim')}}</td>
- <td>{{Spec2('ES5.1')}}</td>
- <td>Définition initiale. Implémentée avec JavaScript 1.8.1.</td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-string.prototype.trim', 'String.prototype.trim')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td> </td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-string.prototype.trim', 'String.prototype.trim')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td> </td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
-
-<p>{{Compat("javascript.builtins.String.trim")}}</p>
-
-<h2 id="Voir_aussi">Voir aussi</h2>
-
-<ul>
- <li>{{jsxref("String.prototype.trimStart()")}}</li>
- <li>{{jsxref("String.prototype.trimEnd()")}}</li>
-</ul>
diff --git a/files/fr/web/javascript/reference/global_objects/string/trim/index.md b/files/fr/web/javascript/reference/global_objects/string/trim/index.md
new file mode 100644
index 0000000000..a36df76b58
--- /dev/null
+++ b/files/fr/web/javascript/reference/global_objects/string/trim/index.md
@@ -0,0 +1,74 @@
+---
+title: String.prototype.trim()
+slug: Web/JavaScript/Reference/Global_Objects/String/Trim
+tags:
+ - ECMAScript 2015
+ - JavaScript
+ - Méthode
+ - Prototype
+ - Reference
+ - String
+ - polyfill
+translation_of: Web/JavaScript/Reference/Global_Objects/String/Trim
+original_slug: Web/JavaScript/Reference/Objets_globaux/String/trim
+---
+{{JSRef}}
+
+La méthode **`trim()`** permet de retirer les blancs en début et fin de chaîne. Les blancs considérés sont les caractères d'espacement (espace, tabulation, espace insécable, etc.) ainsi que les caractères de fin de ligne (LF, CR, etc.).
+
+{{EmbedInteractiveExample("pages/js/string-trim.html")}}
+
+## Syntaxe
+
+ str.trim()
+
+### Valeur de retour
+
+Une nouvelle chaîne de caractères dérivant de la chaîne appelante pour laquelle les blancs ont été retirés aux deux extrémités de la chaîne.
+
+## Description
+
+La méthode `trim()` renvoie la chaîne sans blanc au début et à la fin. La méthode `trim()` n'affecte pas la valeur de la chaîne courante.
+
+## Exemples
+
+L'exemple qui suit affiche la chaîne `'toto'` :
+
+```js
+var chaîneOriginale = ' toto ';
+console.log(chaîneOriginale.trim()); // 'toto'
+
+// Un autre exemple de .trim() qui enlève les espaces juste d'un côté
+
+var chaîneOriginale = 'toto ';
+console.log(chaîneOriginale.trim()); // 'toto'
+```
+
+## Prothèse d'émulation (_polyfill_)
+
+Si l'environnement utilisé ne possède pas cette méthode, il est possible de l'émuler avec le fragment de code suivant :
+
+```js
+if (!String.prototype.trim) {
+  String.prototype.trim = function () {
+ return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
+  };
+}
+```
+
+## Spécifications
+
+| Spécification | État | Commentaires |
+| -------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------- |
+| {{SpecName('ES5.1', '#sec-15.5.4.20', 'String.prototype.trim')}} | {{Spec2('ES5.1')}} | Définition initiale. Implémentée avec JavaScript 1.8.1. |
+| {{SpecName('ES6', '#sec-string.prototype.trim', 'String.prototype.trim')}} | {{Spec2('ES6')}} |   |
+| {{SpecName('ESDraft', '#sec-string.prototype.trim', 'String.prototype.trim')}} | {{Spec2('ESDraft')}} |   |
+
+## Compatibilité des navigateurs
+
+{{Compat("javascript.builtins.String.trim")}}
+
+## Voir aussi
+
+- {{jsxref("String.prototype.trimStart()")}}
+- {{jsxref("String.prototype.trimEnd()")}}