I have a small function which adds a returned result to a list of objects but the problem i have is if there is a certain duplicate it will not allow it – but there are some aspects where duplication occurs and other aspects which do not…
I’ll explain better with example:
var data = {"24":{"16":["172"],"15":["160"]}}
This list of data translates to :
var data = {"X":{"Y":["id"],"Y":["id"]}};
Now im trying to insert new data like this:
for(var key in result){
if(result.hasOwnProperty(key)){
data[key] = result[key];
}
}
If you consider grid co-ordinates, in my list of objects, Y cannot be duplicated in the same X and X can not be duplicated at all.
This is example data of “result” that im trying to insert:
{24: {13:[187]}}
Thus turning var data to :
var data = {"24":{"16":["172"],"15":["160"],"13":["187"]}};
Does any one know how i can implement a duplication check for my loop ?
Something like this should work. If there is a collision, I rebuild the inline object so that I can add it back with all the original and new keys/values.
PS: the last line is just for fun.