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月.
startsWith() は String 値のメソッドで、文字列が引数で指定された文字列で始まるかを判定して true か false を返します。
str の先頭で検索される文字の集合です。正規表現にすることはできません。正規表現ではない値はすべて文字列に変換されますので、省略したり undefined を渡したりすると、startsWith() は "undefined" という文字列を検索します。これはおそらく望むところではないでしょう。
position 省略可searchString が見つかると期待される開始位置(searchString の先頭の文字のインデックス)です。既定値は 0 です。
文字列が指定された文字列で始まる場合、searchString が空文字列の場合は true、それ以外の場合は false です。
searchString が正規表現であった場合。
文字列が特定の文字列で終わるかどうかを判断できます。このメソッドでは(英文字の)大文字小文字は区別されます。
| ECMAScript® 2027 Language Specification # sec-string.prototype.startswith |
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.