→
その String で、指定文字列が指定位置から始まるか否か返します。
String | String。 |
---|---|
searchString | 文字列の先頭で検索される文字の集合です。 |
position | 省略可。searchString を検索し始めるこの文字列の中の位置です。既定値は 0 です。 |
Boolean。文字列が指定された文字列で始まる場合は true、それ以外の場合は false です。
その文字列が、指定の文字列で始まるかどうかを判断できます。(英文字の)大文字・小文字は区別されます。
let str='To be, or not to be, that is the question.'; D=str.startsWith('To be'); //=true D=str.startsWith('not to be'); //=false D=str.startsWith('not to be', 10); //=true