2010-09-11 121 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

相關問題