Subclassing Function

Nelo Mitranim me at
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:

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()
new Sub()

More information about the es-discuss mailing list