Per my answer to this question, chrome allows you to do the following (chrome 49):
class Person {
constructor() {
this.fn = function(a) { this.a = a; };
return new Proxy(this, {
apply: function(target, thisArg, args) {
return target.fn.apply(target, args);
}
});
}
}
var person = new Person();
person(3);
person.a; //3
typeof person; //object
Whereas FF makes you do this:
class Person extends Function {
constructor() {
super();
this.fn = function(a) { this.a = a; };
return new Proxy(this, {
apply: function(target, thisArg, args) {
return target.fn.apply(target, args);
}
});
}
}
var person = new Person();
person(3);
person.a; //3
typeof person; //function
So requiring a call to super
in a subclass constructor that references this
is apparently correct according to MDN, but in terms of allowing a proxy to make a non-function callable, which browser has the correct behavior here? Chrome which lets you, or FF which requires extending Function?
UPDATE
Per Bergi's comment below, relevant spec section is 9.5.14, specifically step 7.
FINAL UPDATE
This is a bug in certain versions of Chrome (I'm too lazy to test exactly which) Chrome 51 at least has the correct behavior of throwing an error.