function XFunction(args, body) {
var func = Function(args, body);
func.__proto__ = Object.create(XFunction.prototype);
return func;
}
XFunction.prototype = Object.create(Function.prototype);
var f = new XFunction("", "return 1");
Function.prototype.test = function () {
return 2;
};
XFunction.prototype.xTest = function () {
return 3;
};
console.log(f()); //1
console.log(f.test()); //2
console.log(f.xTest()); //3
console.log("apply" in f); //true
console.log(f instanceof Function); //true
console.log(f instanceof XFunction); //true
В IE7-9 не работает