Possible Duplicate:
Detecting change in a Javascript Object
Is there any reliable, cross-browser way to detect or "read", new property-names for an object when they get assigned ?
For instance:
var obj = {};
obj.newProperty = true;
I'd like to intercept that process and retrieve "newProperty"
. My ideas so far are these:
- use ES5 getter functions ?
- use Object.watch ?
- use a setInterval to check for new properties ?
I think Object.watch is only available in Firefox, so that actually is no real option. What I need is something like "Mutation events" for native Javascript objects. Help ?