From 844f5103992238c0c23203286dad16a466e89c97 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:09 +0200 Subject: move *.html to *.md --- .../global_objects/string/endswith/index.html | 100 --------------------- 1 file changed, 100 deletions(-) delete mode 100644 files/fr/web/javascript/reference/global_objects/string/endswith/index.html (limited to 'files/fr/web/javascript/reference/global_objects/string/endswith/index.html') 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 ---- -
{{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

- -
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 :

- -
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ÉtatCommentaires
{{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

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