JavaScript Function.prototype.bind() Method
The bind() method creates a new function with this permanently set to a given value, and optionally some arguments filled in.
Description
The bind() method returns a new function whose this is permanently set to the given value, no matter how it is called. This matters when passing methods as callbacks, for example to addEventListener() or setTimeout(), where this would otherwise be lost.
Extra arguments are fixed in front of any passed later, which is called partial application. Arrow functions don't have their own this, so they're often used instead of bind() in modern code.
A bound function can't be re-bound: calling bind() again on it has no effect on this, although extra arguments are still added. Each call to bind() creates a new function, so if you need to remove an event listener later, keep a reference to the bound function rather than binding again.
Syntax
func.bind(thisArg)
func.bind(thisArg, arg1, arg2, ...)Parameters
- thisArgThe value to use as
thiswhen the new function is called. - arg1, arg2, ...Optional. Arguments to put before any passed when calling the new function.
Return Value
A new function with this (and any given arguments) fixed.
Example
Browser Support
The following information will show you the current browser support for the Function.prototype.bind() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





