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: 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...

  4. 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.

  5. 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).

  6. 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 …

  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 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"));

  9. Passing two variables through the .indexOf () in javascript?

    I've been looking through some js source and found someone using the indexOf() method. However, instead of passing a single parameter, they passed two like this: string.indexOf(a,5) where 'a' was a

  10. javascript - How to find the indexes of all occurrences of an element ...

    Dec 27, 2013 · The .indexOf() method has an optional second parameter that specifies the index to start searching from, so you can call it in a loop to find all instances of a particular value: