| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith | [Back] [Original] |
Get to know MDN better
Cette page a t traduite partir de l'anglais par la communaut. Vous pouvez contribuer en rejoignant la communaut francophone sur MDN Web Docs.
Cette fonctionnalit est bien tablie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis septembre 2015.
La mthode startsWith() renvoie un boolen indiquant si la chaine de caractres commence par la deuxime chaine de caractres fournie en argument.
const str1 = "Saturday night plans";
console.log(str1.startsWith("Sat"));
// Expected output: true
console.log(str1.startsWith("Sat", 3));
// Expected output: false
str.startsWith(chaneRecherche [, position]);
chaneRechercheLes caractres rechercher au dbut de la chaine de caractres.
position FacultatifLa position laquelle commencer la recherche de chaneRecherche ; par dfaut 0.
true si la chane de caractres commence avec la sous-chane en argument, false sinon
Cette mthode permet de savoir si une chaine de caractres commence avec une autre chaine de caractres (comme pour les autres mthodes fonctionnant avec les chanes de caractres, cette mthode est sensible la casse).
var str = "tre, ou ne pas tre : telle est la question.";
console.log(str.startsWith("tre")); // true
console.log(str.startsWith("pas tre")); // false
console.log(str.startsWith("pas tre", 12)); // true
| Spcification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string.prototype.startswith |
String.prototype.endsWith()String.prototype.includes()String.prototype.indexOf()String.prototype.lastIndexOf()Cette page a t modifie le 4 sept. 2026 par les contributeurices du MDN.
StringString.prototype.anchor()String.prototype.at()String.prototype.big()String.prototype.blink()String.prototype.bold()String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed()String.prototype.fontcolor()String.prototype.fontsize()String.prototype.includes()String.prototype.indexOf()isWellFormed()String.prototype.italics()String.prototype.lastIndexOf()String.prototype.link()String.prototype.localeCompare()String.prototype.match()String.prototype.matchAll()String.prototype.normalize()String.prototype.padEnd()String.prototype.padStart()String.prototype.repeat()String.prototype.replace()String.prototype.replaceAll()String.prototype.search()String.prototype.slice()String.prototype.small()String.prototype.split()String.prototype.startsWith()String.prototype.strike()String.prototype.sub()String.prototype.substr()String.prototype.substring()String.prototype.sup()String.prototype.toLocaleLowerCase()String.prototype.toLocaleUpperCase()String.prototype.toLowerCase()String.prototype.toString()String.prototype.toUpperCase()toWellFormed()String.prototype.trim()String.prototype.trimEnd()String.prototype.trimStart()String.prototype.valueOf()String.prototype[@@iterator]()Object/FunctionCertaines parties de ce contenu sont protges par le droit d'auteur 19982026 des contributeurs individuels de mozilla.org. Contenu disponible sous une licence Creative Commons.
| Web Proxy Viewer | New URL | Original Page |