简体   繁体   English

JavaScript是否具有与Python的__getattribute__等效的功能?

[英]Does JavaScript have the equivalent of Python's __getattribute__?

Does JavaScript have the equivalent of Python's __getattribute__ ? JavaScript是否具有与Python的__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') . 从某种意义上说,我想要一个对象a ,对其属性x的引用等效于a.__get__('x') Trying to get this to work in V8. 试图使其在V8中工作。 Possible? 可能?

Example: an object which makes REST-ful calls: 示例:进行REST式调用的对象:

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

属性是不可能的,尽管方法有一种非标准的方法( __noSuchMethod__ ),仅适用于Firefox。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM