indexOf indexOf() 会搜索指定字符串出现的位置: var s = 'hello, world'; s.indexOf('world'); // 返回7 s.indexOf('World'); // 没有找到指定的子串,返回-1