About 54 results
Open links in new tab
  1. javascript - Using the indexOf method on an array of objects - Stack ...

    Using the indexOf method on an array of objects Asked 14 years, 1 month ago Modified 5 months ago Viewed 929k times

  2. How does the `indexOf` method on a string work in JavaScript?

    Jan 1, 2022 · The indexOf function of a string does not return a character but rather returns the position of the first place that string or character is found, not the character itself.

  3. javascript - What is the difference between indexOf () and search ...

    Dec 9, 2008 · If your situation requires the use of a regular expression, use the search() method, otherwise; the indexOf() method is more performant.

  4. JavaScript: String.indexOf(...) allowing regular-expressions?

    In javascript, is there an equivalent of String.indexOf (...) that takes a regular expression instead of a string for the first parameter, while still allowing a second parameter ? I need to do some...

  5. javascript - What does a two-argument indexOf method call do?

    Jan 26, 2026 · It counts the number of times e appears in the string overall, using string.indexOf to find each occurence. string.indexOf only returns the position of the first occurence of the character in the …

  6. Difference Between indexOf and findIndex function of array

    Jan 3, 2017 · Furthermore, indexOf () compares searchElement to elements of the Array using strict equality (the same method used by the === or triple-equals operator).

  7. Writing indexOf function in JavaScript - Stack Overflow

    I am new to JavaScript. I have created a indexof function in but it is not giving the correct output: Question is: /* Implement a function called indexOf that accepts two parameters: a string and a …

  8. javascript - Why is indexOf returning -1 if no match has been found ...

    Jun 15, 2018 · 0 indexOf() gives you the position of the element in the array and valid index of array starts from 0, 1, ... and so on till the array.length-1 so if the indexOf() would return 0 for non …

  9. javascript - Why does IndexOf return -1? - Stack Overflow

    Dec 21, 2011 · I am learning Javascript and don't understand why the indexOf below returns -1: var string = "The quick brown fox jumps over the lazy dog"; console.log (string.indexOf("good"));

  10. JavaScript indexOf method with multiple values - Stack Overflow

    JavaScript indexOf method with multiple values Asked 9 years, 10 months ago Modified 4 years, 2 months ago Viewed 67k times