JavaScript's equivalent to PHP's __get() magic method [duplicate]

余生颓废 提交于 2019-12-09 02:35:00

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3959187/javascripts-equivalent-to-phps-get-magic-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!