Standard built-ins
Function.prototype.bind()
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
| Name | Type | Description |
|---|---|---|
| thisArg | Any | Receiver supplied to target; the target controls this handling. |
| args | Any[] | 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());