Standard built-ins

Function.prototype.bind()

Try the free JavaScript compiler

Returns a new bound callable storing a target, receiver and leading arguments. Construction of a constructible bound target ignores bound this.

Formal Syntax & Structure

javascript syntaxjavascript
fn.bind(thisArg, ...args)

Parameters & Attributes

NameTypeDescription
thisArgAnyReceiver supplied to target; the target controls this handling.
argsAny[]Leading arguments to prepend.

Return Value

Function

New bound callable.

Working Example

Example Snippetjavascript
function f(x){return this.n+x;}const g=f.bind({n:4},5);console.log(g());
JavaScript Reference