javascript - How to watch for array changes? - Stack Overflow

PHOTO EMBED

Fri Aug 21 2020 13:41:32 GMT+0000 (Coordinated Universal Time)

Saved by @rdemo #javascript

function processQ() {
   // ... this will be called on each .push
}

var myEventsQ = [];
myEventsQ.push = function() { Array.prototype.push.apply(this, arguments);  processQ();};
content_copyCOPY

https://stackoverflow.com/questions/5100376/how-to-watch-for-array-changes