Subclassing Function
Bradley Meck
bradley.meck at gmail.com
Sat Oct 24 22:34:17 UTC 2015
Why not check `new.target`?
```javascript
function SubFunction() {
// function call
if (new.target === undefined) {
}
// constructor call
else {
}
}
```
On Sat, Oct 24, 2015 at 5:07 PM, Nelo Mitranim <me at mitranim.com> wrote:
> On second thought, a construct method wouldn't add anything that classes
> don't do better. Let's just stick with call:
>
> ```javascript
> class SubFunction extends Function {
> someState = {}
>
> // Assigned as internal [[Call]] property.
> [Symbol.functionCall]() {
> // ...
> }
>
> someMethod() {
> // ...
> }
> }
>
> const sub = new SubFunction()
> sub()
> ```
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151024/ed2ef99d/attachment.html>
More information about the es-discuss
mailing list