About 40,200 results
Open links in new tab
  1. Using the indexOf method on an array of objects - Stack Overflow

    17 I like Pablo's answer, but Array#indexOf and Array#map don't work on all browsers. Underscore will use native code if it's available, but has fallbacks as well. Plus it has the pluck …

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

  3. Difference Between indexOf and findIndex function of array

    Jan 3, 2017 · I am confused between the difference between the two function indexOf and find Index in an array. The documentation says findIndex - Returns the index of the first element in …

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

  5. javascript - indexOf () > -1 vs indexOf () != -1 - Stack Overflow

    Dec 20, 2017 · indexOf returns a -1 if the search is not in the string. This is because indexOf will return the position of the search term in the string. For example is another way of saying …

  6. Why does my List's IndexOf function return -1 even though there's …

    List<T>.IndexOf looks for an item in the list which is equal to the value you pass it. By default, for classes, equality is simply object identity - so two different objects are treated as unequal, …

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

  8. Get the index of the object inside an array, matching a condition

    Apr 14, 2013 · var numberList = [100,200,300,400,500]; var index = numberList.indexOf(200); // 1 You will get -1 if it cannot find a value in the array.

  9. How to get the index of the element in javascript?

    Sep 23, 2010 · The NodeList don't have a indexOf(element) method? So, how can I get the element index?

  10. How to find the indexes of all occurrences of an element in array?

    Dec 27, 2013 · The indexOf recommendation right at the top of the thread in this post is fundamentally inefficient and should be removed. indexOf is simply the wrong tool for the job. …