String
对象的 indexOf()
方法可返回某个指定的字符串值在字符串中首次出现的位置。如果要检索的字符串值没有出现,则该方法返回 -1。
let str = 'hello world'
console.log(str.indexOf('hello') !== -1) // true
String
对象的 indexOf()
方法可返回某个指定的字符串值在字符串中首次出现的位置。如果要检索的字符串值没有出现,则该方法返回 -1。
let str = 'hello world'
console.log(str.indexOf('hello') !== -1) // true