If there are two JSON objects in an array with same value for a particular field, then I want to mark them as duplicate. I want to remove one of them. Similarly, when there are multiple duplicate, I only want to keep the last object(latest).If this is input:
names_array = [
{name: "a", age: 15},
{name: "a", age: 16},
{name: "a", age: 17},
{name: "b", age: 18}
{name: "b", age: 19}];
I want the output to be
names_array_new =
{name: "a", age: 17},
{name: "b", age: 19}];
I have searched for this but only found how to remove duplicates when entire objects are same.