Let say we have an object:
message {
diff: {
cat: "Tabby"
name: "Meow Meow"
}
}
Can you check duplicates with hasOwnProperty() and do a removal of the duplicates? Example
for (key in message.diff) {
//outputs every change when all keys are updated
if (message.diff.hasOwnProperty(key)){
this.uniqueArray.push(key);
}
}
EDIT: I realized there maybe confusion what I am trying to talk about. I have a function that listens to any form element that can be updated which logs the input into console. It is mostly listening to the property names This outputs itself to array which may or may not contain duplicates of names.
If we updated the form fields many, many times, it becomes:
Current Output: ['name', 'name', 'name', 'cat']
Desired Ouput: ['name', 'cat']