6

Other than regularly polling for changes, is there any (standard) way to register an event or callback that will be triggered any time a new property is added to a specific object?

2
  • Might be related: stackoverflow.com/questions/4169524/… Commented Mar 17, 2011 at 14:01
  • @Shadow - detecting a change to an existing property is easy, the question is about detecting addition of new properties. Commented Mar 17, 2011 at 14:15

2 Answers 2

2

Simply put, the answer is no.

Mozilla's JavaScript implementation has an overload for unresolvable methods, but it doesn't work for standard properties, see __noSuchMethod__. Of course, you asked for a standard method and no other implementations support this as far as I'm aware.

Sign up to request clarification or add additional context in comments.

2 Comments

I rather suspected as much, but figured a decent set of answers and/or workarounds in one place would be of benefit.
@Alnitak: I went looking for an answer to the same question a long time ago. Perhaps we'll see something like this standardized in a future revision of the specification.
1

Once upon a time, ActionScript supported the __resolve property. As far as I know, JS has no similar crossbrowser construct, but maybe you could simulate it with some simple (but still bloaty) accessor function, like this:

http://bytes.com/topic/javascript/answers/789987-does-javascript-support-some-kind-__resolve-method

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.