Subclassing Function
Nelo Mitranim
me at mitranim.com
Sat Oct 24 19:53:15 UTC 2015
While creating functions from strings is useful, I would much prefer being able to define call and construct methods in the source. Something like:
```javascript
class SubFunction extends Function {
// Assigned as internal [[Call]] property.
[Symbol.functionCall]() {
return true
}
// Optional [[Construct]] override. If included, will be used instead of
// [[Call]] when called with `new`.
[Symbol.construct]() {
// ...
}
}
const Sub = new SubFunction()
Sub()
new Sub()
```
More information about the es-discuss
mailing list