Subclassing Function

Nelo Mitranim me at mitranim.com
Sun Oct 25 08:39:56 UTC 2015


@Jordan The linked proposal is what inspired the dual-method part (which I backed away from) of my suggestion.

How we define the call/construct methods of a _class_ is actually orthogonal to how we define the call method of an _instance_ of the hypothetical function subclass. If anything, they have to be keyed separately. Example:

```javascript
class SubFunction extends Function {
  constructor() {
    // "static" constructor function, sets up instance state
  }

  call constructor () {
    // hypothetical "static function" version of class
  }

  [Symbol.functionCall]() {
    // body of class instance function
  }
}
```


More information about the es-discuss mailing list