[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith [Back]  [Original]

String.prototype.endsWith() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

String.prototype.endsWith()

Baseline

20159

endsWith() String true false

const str1 = "Cats are the best!";

console.log(str1.endsWith("best!"));
// : true

console.log(str1.endsWith("best", 17));
// : true

const str2 = "Is this a question?";

console.log(str2.endsWith("question"));
// : false

js
endsWith(searchString)
endsWith(searchString, endPosition)

searchString

str undefined endsWith() "undefined"

endPosition

searchString searchString +1 str.length

searchString true false

TypeError

searchString

endsWith()

js
const str = "To be, or not to be, that is the question.";

console.log(str.endsWith("question.")); // true
console.log(str.endsWith("to be")); // false
console.log(str.endsWith("to be", 19)); // true

ECMAScript 2027 LanguageSpecification
# sec-string.prototype.endswith


Web Proxy Viewer  |  New URL  |  Original Page