Es6-string-prototype-startswith
提供:Dev Guides
ES6-String.prototype.startsWith()
文字列が指定された文字列の文字で始まるかどうかを決定します。 この関数は、trueまたはfalseを返します。
構文
以下に示す構文は* String.prototype.startsWith()用です。ここで、 *searchString は、この文字列の先頭で検索される文字です。 position はオプションのパラメーターです。 これは、 searchString の検索を開始するこの文字列の位置を表します。 デフォルト値は0です。
str.startsWith(searchString[, position])
例
let company='finddevguides'
console.log(company.startsWith('Tutorial'))
console.log(company.startsWith('orial',3))//3 is index
上記のコードの出力は以下のようになります-
true
true