よく忘れるのでメモ。
'検索される文字列'.indexOf('検索') != -1
indexOf
はtrue/falseを返さない。
一致した文字列が何文字目から始まるかを返す。検索文字列が存在しなかった場合は-1を返す。
> '検索される文字列'.indexOf('検索') != -1
> true
> '検索される文字列'.indexOf('あ') != -1
> false
More than 5 years have passed since last update.
よく忘れるのでメモ。
'検索される文字列'.indexOf('検索') != -1
indexOf
はtrue/falseを返さない。
一致した文字列が何文字目から始まるかを返す。検索文字列が存在しなかった場合は-1を返す。
> '検索される文字列'.indexOf('検索') != -1
> true
> '検索される文字列'.indexOf('あ') != -1
> false
Register as a new user and use Qiita more conveniently