Function.prototype.mybind = function (context) { let self = this, args = Array.prototype.slice.call(arguments, 1), fBound = function () { let bindArgs = Array.prototype.slice.call(arguments) return self.apply(this instanceof fBound ? this : context, args.concat(bindArgs)) } if (this.prototype) { fBound.prototype = Object.create(this.prototype) } return fBound }