I have an array:
var arr = [
{price: 5, amount: 100},
{price: 3, amount: 50},
{price: 10, amount: 20},
{price: 3, amount: 75},
{price: 7, amount: 1
I'd use reduceRight and splice to remove duplicates. It doesn't create any useless intermediate objects, just a list of unique prices found along the way:
var arr = [
{price: 5, amount: 100},
{price: 3, amount: 50},
{price: 10, amount: 20},
{price: 3, amount: 75},
{price: 7, amount: 15},
{price: 3, amount: 65},
{price: 2, amount: 34}
]
arr.reduceRight((acc, obj, i) => {
acc[obj.price]? arr.splice(i, 1) : acc[obj.price] = true;
return acc;
}, Object.create(null));
arr.sort((a, b) => b.price - a.price);
console.log(arr)