javascript check for duplicates in array of objects