2010-09-11 88 views
0

JavaScript是否与Python的__getattribute__等效?从某种意义上说,我想要一个对象,a,对于它的引用属性x相当于a.__get__('x')。试图让这个工作在V8中。可能?JavaScript是否与Python的__getattribute__等价吗?

实施例:一个目的,这使得REST-FUL呼叫:

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

你能举一个你想要完成的例子吗? – Guffa 2010-09-11 10:03:20

+1

[在JavaScript中捕获对未定义属性的访问]的可能副本(http://stackoverflow.com/questions/2756431/catch-access-to-undefined-property-in-javascript)和[是否有__noSuchMethod__功能的等效项为属性,或在JS中实现它的方式?](http://stackoverflow.com/questions/2266789/is-there-an-equivalent-of-the-nosuchmethod-feature-for-properties-or-a- way-t) – Anurag 2010-09-11 20:39:11

回答

2

这是不可能的特性,尽管存在用于该方法仅可用于火狐非标准方式(__noSuchMethod__)。

+0

[ES-Harmony Proxies](http://stackoverflow.com/questions/2266789/is-there-an-equivalent-of-the-nosuchmethod-feature-for-properties-or-a-way- t/3757676#3757676)拯救:) – CMS 2010-09-24 06:09:35

相关问题