How to extend Function with ES6 classes?

The super call will invoke the Function constructor, which expects a code string. If you want to access your instance data, you could just hardcode it: class Smth extends Function { constructor(x) { super(“return “+JSON.stringify(x)+”;”); } } but that’s not really satisfying. We want to use a closure. Having the returned function be a closure … Read more