DEV Community

Discussion on: Function.bind.bind does not work in JavaScript

Collapse
 
qm3ster profile image
Mihail Malo • Edited

Ignoring binding arguments, just .bind(thisArg) can be visualized as following:

Function.prototype.bind = function bind(thisArg) {
  return (...args) => this.apply(thisArg, args)
}

Here it is clear that the returned function doesn't care about this.

Same thing, without arrow function:

Function.prototype.bind = function bind(thisArg) {
  const self = this
  return function(...args) { // could have access to `this`, but doesn't make use of it.
    return self.apply(thisArg, args)
  }
}