I am looking for a way to determine if an object has new subobjects. Specifically, I have an object with multiple nested objects and I want to check if the main object has any new objects added to it. Is there an existing method to achieve this?
methods: {
playSound(newOrders, sound) {
if (newOrders.length > 0) {
if (sound) {
var audio = new Audio(sound);
audio.play();
}
}
}
},
beforeUpdate() {
this.playSound(this.newOrders, 'http://soundbible.com/mp3/Elevator Ding-SoundBible.com-685385892.mp3')
},
My objective is to invoke the playSound
function only when the newOrders
object has new items. Currently, the code executes the function whenever the array changes, even if items are removed, which is incorrect. Any suggestions on how to correct this behavior?