Answers for "find all the obg in array by same id in js"

1

find duplicate values in array object javascript

function getUnique(arr, comp) {

                    // store the comparison  values in array
   const unique =  arr.map(e => e[comp])

                  // store the indexes of the unique objects
                  .map((e, i, final) => final.indexOf(e) === i && i)

                  // eliminate the false indexes & return unique objects
                 .filter((e) => arr[e]).map(e => arr[e]);

   return unique;
}

console.log(getUnique(arr,'id'));
Posted by: Guest on November-09-2020
0

find how many similar object item in an array in javascript

const counts = {};
your_array.forEach(function(x.name) { counts[x.name] = (counts[x.name] || 0)+1; });
Posted by: Guest on October-07-2021

Code answers related to "find all the obg in array by same id in js"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language