13

Possible Duplicate:
JavaScript getter for all properties

Does JavaScript provide a method to access undefined object properties? In PHP the solution is to declare and implement __get() method in class.
Solutions using try { .. } catch { .. } are not sufficient for me, because I already have very large amount of code which actually needs to stay as-is.

Community
  • 1
  • 1
Michal Pietrzyk
  • 131
  • 1
  • 1
  • 5
  • 4
    possible duplicate of [JavaScript getter for all properties](http://stackoverflow.com/questions/994143/javascript-getter-for-all-properties) - there is not exact equivalent to `__get` but there is `__defineGetter__`. – Gordon Oct 18 '10 at 12:41
  • 1
    @Gordon: *Object.defineProperty()* is the standards compliant method of defining getters now. – Andy E Oct 18 '10 at 12:52
  • @Haim: That link simply rips off the content at http://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method **Always post the SO content link over that other site!** – Roatin Marth Oct 18 '10 at 12:54
  • @AndyE thanks for the information. You might want to add it as an answer to the linked question. – Gordon Oct 18 '10 at 12:57
  • See http://stackoverflow.com/questions/7891937/is-it-possible-to-implement-dynamic-getters-setters-in-javascript – Codler Mar 08 '14 at 08:39

1 Answers1

0

You may choose to write a similar functionality and check existing parameters them against the arguments array. I'm not 100% that this will solve your problem.

Elzo Valugi
  • 27,240
  • 15
  • 95
  • 114