I have an empty array: "testList = []" I want to have a function that adds objects only if it exists:
addIfNotInList({'keya':'a','keyb':'b'}, testList);
addIfNotInList({'keya1':'a5','keyb':'b2'}, testList);
addIfNotInList({'keya':'a','keyb':'b'}, testList);
The result of this should be:
testList = [{'keya':'a','keyb':'b'},{'keya1':'a5','keyb':'b2'}]
Usually if it were not an object, I would just do: if(testList.indexOf(stringvalue)) {testList.push(stringvalue)}
Though I've discovered this does not work with objects.