Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年9月.
endsWith() は String 値のメソッドで、文字列が引数で指定された文字列で終わるかを判定して true か false を返します。
str の末尾で検索される文字の集合です。正規表現にすることはできません。正規表現ではない値はすべて文字列に変換されますので、省略したり undefined を渡したりすると、endsWith() は "undefined" という文字列を検索します。これはおそらく望むところではないでしょう。
endPosition 省略可searchString が見つかると期待される末尾の位置(searchString の最後の文字 +1 のインデックス)です。既定値は str.length です。
文字列が指定された文字列で終わる場合、searchString が空文字列の場合は true、それ以外の場合は false です。
searchString が正規表現であった場合。
文字列が特定の文字列で終わるかどうかを判断できます。このメソッドでは(英文字の)大文字小文字は区別されます。
| ECMAScript® 2027 Language Specification # sec-string.prototype.endswith |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月22日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.