I have javascript object list and object like this
var student = function (config)
{
config = config || {}
this.id = config.id || 1;
this.Name = config.Name || "Shohel";
this.Roll = config.Roll || "04115407";
this.Session = config.Session || "03-04";
this.Subject = config.Subject || "CSE";
};
var students = [];
students.push(new student({ id: 2 }));
students.push(new student({ id: 3, Name: "Rana" }));
students.push(new student({ id: 4, Name: "Shipon" }));
students.push(new student({ id: 5, Name: "Pira" }));
Now I want to push another object like this
students.push(new student({ id: 3, Name: "Rana" }));
It is working without any exceptions but I want to check whether this object whose
id is: 3 and Name:"Rana"
already exists in the students list and whether I have too many lists like customers, products, sales etc. then duplicate checking is not possible for every list for me. It will be a hassle for me.
How can I make a generic method for any type of list in javascript that can check for duplicates ?