方法1 :indexOf
? var str = 'objectarray123456'
? console.log(str.indexOf('array')) //6
方法2:search
?var str = 'objectarray123456'
console.log(str.search('123')) //11
方法3: match
var reg = /array/g
?console.log(str.match(reg)) //["array"]
方法4: test
var reg = /array/g
?console.log(reg.test(str)) //true
方法5:
var reg = /array/
console.log(reg.exec(str)) //["array", index: 6, input: "objectarray123456", groups: undefined]