You could filter it with a hash table.
var newarray = [{ Email: "test1@gmail.com", ID: "A" }, { Email: "test2@gmail.com", ID: "B" }, { Email: "test3@gmail.com", ID: "A" }, { Email: "test4@gmail.com", ID: "C" }, { Email: "test5@gmail.com", ID: "C" }],
filtered = newarray.filter(function (a) {
if (!this[a.ID]) {
this[a.ID] = true;
return true;
}
}, Object.create(null));
console.log(filtered);
.as-console-wrapper { max-height: 100% !important; top: 0; }
ES6 with Set
var newarray = [{ Email: "test1@gmail.com", ID: "A" }, { Email: "test2@gmail.com", ID: "B" }, { Email: "test3@gmail.com", ID: "A" }, { Email: "test4@gmail.com", ID: "C" }, { Email: "test5@gmail.com", ID: "C" }],
filtered = newarray.filter((s => a => !s.has(a.ID) && s.add(a.ID))(new Set));
console.log(filtered);
.as-console-wrapper { max-height: 100% !important; top: 0; }