Es6-string-prototype-includes

提供:Dev Guides
移動先:案内検索

ES6-String.prototype.includes()

この関数は、ある文字列が別の文字列内で見つかるかどうかを決定します。

構文

次の構文は* String.prototype.includes()用です。ここで、 *searchString はこの string position 内で検索される文字列で、オプションのパラメーターです。 これは、 searchString の検索を開始するこの文字列の位置を表します。 デフォルト値は0です。

str.includes(searchString[, position])

<script>
   let company='finddevguides'
   console.log(company.includes('orial'))
   console.log(company.includes('orial',4))
</script>

上記のコードの出力は以下のようになります-

true
false