aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/string/endswith
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/endswith
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/endswith')
-rw-r--r--files/fr/web/javascript/reference/global_objects/string/endswith/index.html100
-rw-r--r--files/fr/web/javascript/reference/global_objects/string/endswith/index.md83
2 files changed, 83 insertions, 100 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/string/endswith/index.html b/files/fr/web/javascript/reference/global_objects/string/endswith/index.html
deleted file mode 100644
index 170935fb6e..0000000000
--- a/files/fr/web/javascript/reference/global_objects/string/endswith/index.html
+++ /dev/null
@@ -1,100 +0,0 @@
----
-title: String.prototype.endsWith()
-slug: Web/JavaScript/Reference/Global_Objects/String/endsWith
-tags:
- - JavaScript
- - Méthode
- - Prototype
- - Reference
- - String
- - polyfill
-translation_of: Web/JavaScript/Reference/Global_Objects/String/endsWith
-original_slug: Web/JavaScript/Reference/Objets_globaux/String/endsWith
----
-<div>{{JSRef}}</div>
-
-<p>La méthode <code><strong>endsWith()</strong></code> renvoie un booléen indiquant si la chaine de caractères se termine par la chaine de caractères fournie en argument.</p>
-
-<div>{{EmbedInteractiveExample("pages/js/string-endswith.html")}}</div>
-
-<h2 id="Syntaxe">Syntaxe</h2>
-
-<pre class="syntaxbox"><var>str</var>.endsWith(chaîneRecherchée[, <var>position</var>]);</pre>
-
-<h3 id="Paramètres">Paramètres</h3>
-
-<dl>
- <dt><code>chaîneRecherchée</code></dt>
- <dd>Les caractères à rechercher à la fin de la chaine de caractères.</dd>
- <dt><code>position</code> {{optional_inline}}</dt>
- <dd>Paramètre optionnel. Permet de rechercher dans la chaine de caractères comme si elle faisait cette longueur ; par défaut il s'agit de la longueur de la chaine de caractères <code>chaîneRecherchée</code>. Si la valeur fournie est supérieure à la longueur de la chaine de caractères, elle ne sera pas prise en compte.</dd>
-</dl>
-
-<h3 id="Valeur_de_retour">Valeur de retour</h3>
-
-<p><code>true</code> si la chaîne de caractères se termine par la sous-chaîne indiquée, <code>false</code> sinon.</p>
-
-<h2 id="Description">Description</h2>
-
-<p>Cette méthode permet de savoir si une chaine de caractères se termine avec une certaine chaine de caractères (comme les autres méthodes fonctionnant avec des chaînes de caractères, cette méthode est sensible à la casse).</p>
-
-<h2 id="Exemples">Exemples</h2>
-
-<pre class="brush:js;">var str = "Être, ou ne pas être : telle est la question.";
-
-console.log(str.endsWith("question.")); // true
-console.log(str.endsWith("pas être")); // false
-console.log(str.endsWith("pas être", 20)); // true
-</pre>
-
-<h2 id="Prothèse_d'émulation_(polyfill)">Prothèse d'émulation (<em>polyfill</em>)</h2>
-
-<p>Cette méthode a été ajoutée dans la spécification ECMAScript 6 et peut ne pas être disponible dans toutes les implémentations de JavaScript. Cependant, il est possible d'émuler le comportement de <code>String.prototype.endsWith</code> avec le fragment de code suivant :</p>
-
-<pre class="brush: js">if (!String.prototype.endsWith) {
- String.prototype.endsWith = function(searchString, position) {
-   var subjectString = this.toString();
-    if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position &gt; subjectString.length) {
-   position = subjectString.length;
- }
- position -= searchString.length;
- var lastIndex = subjectString.lastIndexOf(searchString, position);
-    return lastIndex !== -1 &amp;&amp; lastIndex === position;
- };
-}
-</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('ES6', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td>Définition initiale.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td> </td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
-
-<p>{{Compat("javascript.builtins.String.endsWith")}}</p>
-
-<h2 id="Voir_aussi">Voir aussi</h2>
-
-<ul>
- <li>{{jsxref("String.prototype.startsWith()")}}</li>
- <li>{{jsxref("String.prototype.includes()")}}</li>
- <li>{{jsxref("String.prototype.indexOf()")}}</li>
- <li>{{jsxref("String.prototype.lastIndexOf()")}}</li>
-</ul>
diff --git a/files/fr/web/javascript/reference/global_objects/string/endswith/index.md b/files/fr/web/javascript/reference/global_objects/string/endswith/index.md
new file mode 100644
index 0000000000..ce3dc39e2d
--- /dev/null
+++ b/files/fr/web/javascript/reference/global_objects/string/endswith/index.md
@@ -0,0 +1,83 @@
+---
+title: String.prototype.endsWith()
+slug: Web/JavaScript/Reference/Global_Objects/String/endsWith
+tags:
+ - JavaScript
+ - Méthode
+ - Prototype
+ - Reference
+ - String
+ - polyfill
+translation_of: Web/JavaScript/Reference/Global_Objects/String/endsWith
+original_slug: Web/JavaScript/Reference/Objets_globaux/String/endsWith
+---
+{{JSRef}}
+
+La méthode **`endsWith()`** renvoie un booléen indiquant si la chaine de caractères se termine par la chaine de caractères fournie en argument.
+
+{{EmbedInteractiveExample("pages/js/string-endswith.html")}}
+
+## Syntaxe
+
+ str.endsWith(chaîneRecherchée[, position]);
+
+### Paramètres
+
+- `chaîneRecherchée`
+ - : Les caractères à rechercher à la fin de la chaine de caractères.
+- `position` {{optional_inline}}
+ - : Paramètre optionnel. Permet de rechercher dans la chaine de caractères comme si elle faisait cette longueur ; par défaut il s'agit de la longueur de la chaine de caractères `chaîneRecherchée`. Si la valeur fournie est supérieure à la longueur de la chaine de caractères, elle ne sera pas prise en compte.
+
+### Valeur de retour
+
+`true` si la chaîne de caractères se termine par la sous-chaîne indiquée, `false` sinon.
+
+## Description
+
+Cette méthode permet de savoir si une chaine de caractères se termine avec une certaine chaine de caractères (comme les autres méthodes fonctionnant avec des chaînes de caractères, cette méthode est sensible à la casse).
+
+## Exemples
+
+```js
+var str = "Être, ou ne pas être : telle est la question.";
+
+console.log(str.endsWith("question.")); // true
+console.log(str.endsWith("pas être")); // false
+console.log(str.endsWith("pas être", 20)); // true
+```
+
+## Prothèse d'émulation (_polyfill_)
+
+Cette méthode a été ajoutée dans la spécification ECMAScript 6 et peut ne pas être disponible dans toutes les implémentations de JavaScript. Cependant, il est possible d'émuler le comportement de `String.prototype.endsWith` avec le fragment de code suivant :
+
+```js
+if (!String.prototype.endsWith) {
+ String.prototype.endsWith = function(searchString, position) {
+   var subjectString = this.toString();
+    if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
+   position = subjectString.length;
+ }
+ position -= searchString.length;
+ var lastIndex = subjectString.lastIndexOf(searchString, position);
+    return lastIndex !== -1 && lastIndex === position;
+ };
+}
+```
+
+## Spécifications
+
+| Spécification | État | Commentaires |
+| -------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------- |
+| {{SpecName('ES6', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}} | {{Spec2('ES6')}} | Définition initiale. |
+| {{SpecName('ESDraft', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}} | {{Spec2('ESDraft')}} |   |
+
+## Compatibilité des navigateurs
+
+{{Compat("javascript.builtins.String.endsWith")}}
+
+## Voir aussi
+
+- {{jsxref("String.prototype.startsWith()")}}
+- {{jsxref("String.prototype.includes()")}}
+- {{jsxref("String.prototype.indexOf()")}}
+- {{jsxref("String.prototype.lastIndexOf()")}}