Const
The call/return signature that instances of the class will implement.
A unique function or closure, to be passed to super() in a
subclass. The function object will gain a prototype from new.target
,
thereby picking up any properties or methods defined by the class, and
becoming this
for the calling constructor.
(Note that calling the constructor by any means other than super() from a constructor will result in an error or some other unhelpful result.)
A base class for creating callable objects.
The way this works is that you subclass CallableObject and define a constructor that calls
super(someClosure)
wheresomeClosure
is a unique function object, which will then pick up any properties or methods defined by the subclass.(Note: It needs to be unique because the
super()
call only sets its prototype, and returns the function you passed asthis
. So if you call it with the same function more than once, you're just reinitializing the same object instead of creating a new one.)