--- title: String.prototype.padEnd() slug: Web/JavaScript/Reference/Global_Objects/String/padEnd tags: - JavaScript - Méthode - Reference - String translation_of: Web/JavaScript/Reference/Global_Objects/String/padEnd original_slug: Web/JavaScript/Reference/Objets_globaux/String/padEnd ---
La méthode padEnd()
permet de compléter la chaîne courante avec une chaîne de caractères donnée afin d'obtenir une chaîne de longueur fixée. Pour atteindre cette longueur, la chaîne complémentaire peut être répétée. La chaîne courante est complétée depuis la fin.
str.padEnd(longueurCible [, chaîneComplémentaire])
longueurCible
chaîneComplémentaire
{{optional_inline}}Une chaîne de caractères ({{jsxref("String")}}) dont la longueur est celle indiquée, complétée avec la chaîne fournie.
'abc'.padEnd(10); // "abc " 'abc'.padEnd(10, "toto"); // "abctototot" 'abc'.padEnd(6,"123456"); // "abc123" 'abc'.padEnd(1); // "abc"
Spécification | État | Commentaires |
---|---|---|
{{SpecName('ESDraft', '#sec-string.prototype.padend', 'String.prototype.padEnd')}} | {{Spec2('ESDraft')}} | |
{{SpecName('ES8', '#sec-string.prototype.padend', 'String.prototype.padEnd')}} | {{Spec2('ES8')}} | Définition initiale. |
{{Compat("javascript.builtins.String.padEnd")}}