[Solved] Javascript Loop over array of objects and get unique values


Try this

 let  newArray = [];
 carArray.forEach(function(car) {
   let arrayKey = Object.keys(car)[0]
   if (newArray.length > 0) {
       newArray.find(function (data) {
         if(!data.hasOwnProperty(Object.keys(data)[0])) { 
            newArray.push(car);
         }
       })
    }  else newArray.push(car)
 });

6

solved Javascript Loop over array of objects and get unique values