Es6-string-method-includes
提供:Dev Guides
ES6-新しい文字列メソッドinclude()
このメソッドは、文字列が指定された文字列の部分文字列かどうかを判断します。
構文
str.includes(searchString[, position])
パラメーター
- searchString -検索するサブストリング。
- 位置-searchStringの検索を開始するこの文字列内の位置。デフォルトは0です。
戻り値
文字列に部分文字列が含まれる場合、 true 。それ以外の場合は、 false 。
例
var str = 'Hello World';
console.log(str.includes('hell'))
console.log(str.includes('Hell'));
console.log(str.includes('or'));
console.log(str.includes('or',1))
出力
false
true
true
true