Yahoo India Web Search

Search results

  1. Sep 2, 2015 · Easiest way to find duplicate values in a javascript array. How do I check if an array has duplicate values? If some elements in the array are the same, then return true. Otherwise, return false. ['hello','goodbye','hey'] //return false because no duplicates exist ['hello','goodbye','hello'] // return true because duplicates exist

  2. Jun 12, 2024 · There are several methods that can be used to find duplicate elements in an array by using JavaScript, which are listed below: Table of Content. Approach 1: Using Nested For In Loop. Approach 2: Using Sort () Method. Approach 3: Using filter () Method. Approach 4: Using a Single Loop. Approach 5: Using a Set. Approach 6: Using Reduce Method.

  3. Jul 3, 2021 · How to find duplicates in an array using JavaScript. July 03, 2021. In this article 👇. There are multiple methods available to check if an array contains duplicate values in JavaScript. You can use the indexOf() method, the Set object, or iteration to identify repeated items in an array. Set Object.

  4. Learn 10 different ways to find duplicate elements in an array in JavaScript. A performance comparison of each method is also given in form of race chart.

  5. May 8, 2009 · Find duplicate values in an array. This should be one of the shortest ways to actually find duplicate values in an array. As specifically asked for by the OP, this does not remove duplicates but finds them.

  6. Mar 14, 2022 · To find duplicates in an array using JavaScript, the Set object combined with the has() method offers an effective solution. A Set is a collection of unique values, and the has() method determines whether a Set object contains a specified element.

  7. I am trying to get duplicate objects within an array of objects. Let's say the object is like below. values = [. { id: 10, name: 'someName1' }, { id: 10, name: 'someName2' }, { id: 11, name: 'someName3' }, { id: 12, name: 'someName4' } ]; Duplicate objects should return like below: