String object-> indexOf () method

1. Definition and usage

  The indexOf () method returns the first occurrence of a specified string value in the string, that is, the subscript.

  If no matching string is found, -1 is returned.

  grammar:

    string.indexOf(searchvalue,start)

    parameter:

      searchvalue: Specifies the string value to be retrieved.

      start: Specifies the position (subscript) to start searching in the character string

  Note: The  indexOf () method is case sensitive.

  Examples:

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

  Output:

Guess you like

Origin www.cnblogs.com/abner-pan/p/12701047.html