Does JavaScript have the equivalent of Python's __getattribute__?

寵の児 提交于 2019-12-13 03:01:58

问题


Does JavaScript have the equivalent of Python's __getattribute__? In the sense that I'd like an object, a, for which a reference to a property x is equivalent to a.__get__('x'). Trying to get this to work in V8. Possible?

Example: an object which makes REST-ful calls:

RESTful("some-url").foo({x:1}) => response of call to "some-url/foo?x=1"

回答1:


It is not possible for properties, though there is a non-standard way (__noSuchMethod__) for methods which is only available for Firefox.



来源:https://stackoverflow.com/questions/3690394/does-javascript-have-the-equivalent-of-pythons-getattribute

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