The Function constructor accepts arguments:
new Function ([arg1[, arg2[, ...argN]],] functionBody)
That being the case, you'd call super with appropriate arguments:
// SNIPPET ONLY WORKS ON ES2015-ENABLED ENVIRONMENTS
"use strict";
class Foo extends Function {
constructor() {
super("a", "console.log(a);")
}
}
let foo = new Foo();
foo("one");
foo.call(null, "two");
Now, it's a pain to write JavaScript code inside a string literal, and the code within the function text is evaluated at global scope so we can't do something like defining the actual function within the constructor and calling to it from the function text. So this is of limited use. But...
Function" Why? What's the underlying goal?