I am using Set, I am able to store unique primitive values in it, but I am not able to store unique objects in it based on their property values.
Here is my sample code :
"use strict"
var set = new Set();
var student1 = {
"name":"abc",
"id":1
}
var student2 = {
"name":"xyz",
"id":1
}
var student3 = {
"name":"def",
"id":3
}
set.add(student1);
set.add(student2);
set.add(student3);
console.log(set);
I want to add student object in set based on theier ID values i.e. two objects will be same if the values of their ID's are same.