Pergunta

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"
Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top