title | tags | order | date | answers | |||||
---|---|---|---|---|---|---|---|---|---|
String Methods |
|
34 |
2019-10-06 |
|
String methods are used to work with string in JavaScript. Which method would be used to find a specified value and return the position of the match?
For example, what method would tell you that "bird"
is at position 4
in the following word
string?
const word = 'The bird is the word';
The indexOf
method searches a string for a specified value and returns the position of the match. In this example, word.indexOf("bird")
will equal 4
.