JavaScript是否与Python的__getattribute__等价? [英] Does JavaScript have the equivalent of Python's __getattribute__?

查看:112
本文介绍了JavaScript是否与Python的__getattribute__等价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript是否等价于Python的 __ getattribute __ ?从某种意义上说,我想要一个对象, a ,对于这个对象,对 x 的引用相当于 A .__得到__( 'X')。试图让这个工作在V8中。可能吗?

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?

示例:一个可以调用REST的对象:

Example: an object which makes REST-ful calls:

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


推荐答案

对于属性来说这是不可能的,尽管有一种非标准的方式( __ noSuchMethod __ )仅适用于Firefox的方法。

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

这篇关于JavaScript是否与Python的__getattribute__等价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆