The ECMA standard defines a hidden, internal property [[Call]]
, which, if implemented, mean the object is callable / is a function.
In Python, something similar takes place, except that you can override it yourself to create your own callable objects:
>>> class B:
... def __call__(self, x,y): print x,y
...
>>> inst = B()
>>> inst(1,2)
1, 2
Is there any similar mechanism available in standard JavaScript? If not, what about any of the current JavaScript implementations?