indexOf():返回某个指定的字符串值在字符串中首次出现的位置。
var str ="Hello world!";
var res = str.indexOf("o");
console.log(res);//打印7
lastIndexOf():从后向前搜索指定字符串出现的最后位置。
var res = str.lastIndexOf("o");
console.log(res);//打印7 两个o,我们找的是o最后一次出现的位置
2641


&spm=1001.2101.3001.11974&articleId=106590996&d=1&t=3&u=ef7d1523789e4aa1a7083253a57a8084)

被折叠的 条评论
为什么被折叠?



