ES5 functions always had Function.prototype
as their prototype, so it was only logical to have the same for bound functions.
ES6 introduced classes, where the constructors inherit from their superclass constructor, and generator functions, which have their own prototype. If you bind one of them, the bound function should reflect this:
class A {
constructor(x) { this.x = x; }
static example() { return "works" }
}
class B extends A {}
const a1 = new A(1) // {x: 1}
const b1 = new B(1) // {x: 1}
A.example() // "works"
B.example() // "works" - because of inheritance
const BoundA = A.bind(null, 2), BoundB = B.bind(null, 2);
const a2 = new BoundA() // {x: 2}
const b2 = new BoundB() // {x: 2}
BoundA.example() // uh, doesn't actually work
BoundB.example() // "works" - because of the change to bind
Maybe a better use case would be testing for the type of a function (which you shouldn't do though):
const GeneratorFunction = (function*(){}).constructor;
function* example() {
…
}
test instanceof GeneratorFunction // true
test.bind() instanceof GeneratorFunction; // true as well!