In javascript is it faster to compare via a property or the entire object that has tons of properties? Below is what I currently have but my object has a ton of properties, and the objects list is quite large. Is it better to create a list from a single property off say id and compare the id of the object? objectids.indexOf(object1.id). Would I see a performance increase?
Comparing Against The Object
objects.indexOf(object1);
function Object() {
this.id = 1;
this.name = "test";
}
indexOfwill compare object references, so you'd need to show how you're populatingobjectsto know if it would even work...indexOfby object reference is roughly twice as fast as doing anindexOfby ID.