String 对象-->indexOf() 方法

1.定义和用法

  indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置,即下标。

  如果没有找到匹配的字符串则返回 -1。

  语法:

    string.indexOf(searchvalue,start)

    参数:

      searchvalue:规定需检索的字符串值。

      start:规定在字符串中开始检索的位置(下标)

  注意: indexOf() 方法区分大小写。

  举例:

var str = 'abbc'
console.log(str.indexOf('b'))

  输出:

原文地址:https://www.cnblogs.com/abner-pan/p/12701047.html