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 <[email protected]> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to