Determine if a value is Callable/Constructible

Kevin Smith zenparsing at gmail.com
Mon Mar 30 15:39:25 UTC 2015


>
> It doesn’t seem right that you should have to introduce an observable
> prototype property just to get [[Call]] behavior. (Or a constructor
> property, if you change the syntax to `static [Symbol.call]() { … }`.)
>
> And it raises the question of what happens when I add a [Symbol.call]
> property to other objects. What does it even mean? If I do `var obj = {
> prototype: { [Symbol.call]() { console.log("foo"); } } }`, can I now call
> `obj()`? Is `typeof obj === "function"`? Very strange stuff. Presumably not
> very VM-friendly either, but that's just a guess.
>

I'd imagine that you'd re-spec [[Call]] for class constructors to basically
do `this[Symbol.call](...args)` instead of just throw.  It would therefore
only have an effect within class constructors.  Is that still weird?

Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150330/3983b037/attachment.html>


More information about the es-discuss mailing list