liveBook · Manning

Function binding

Also called bind

Function binding is the creation of a function with a predetermined this value and, optionally, preset arguments.

How 2 Manning books explain it

Functional Programming in JavaScript

The technique of associating a function with a specific this value or preset arguments so it can be invoked in a controlled context.

How it is used
Uses preset arguments to turn general functions into modular, reusable operations.
How deep it goes
Defines binding, contrasts it with currying and partial application, and demonstrates configured callbacks without detailing binding internals.
Examples
Demonstrates a bound logger, partially configured string methods, and scheduled callbacks.
What you can do after
Apply it via Lodash _.bind or JavaScript Function.prototype.bind to create configured functions.

Read how Functional Programming in JavaScript explains function binding →

The Joy of JavaScript

The JavaScript method that creates a new function with a bound this value and optional leading arguments.

How it is used
Uses bind to repair a method's this reference while composing functions around object state.
How deep it goes
Explains context correction, partial argument application, and maintainability tradeoffs before shifting to explicit parameters.
Examples
Uses assemble.bind(this, keys) inside calculateHash and contrasts it with assemble(keys, obj).
What you can do after
Apply it via JavaScript's bind method to preserve object context and prefill keys, while recognizing its maintainability cost.

Read how The Joy of JavaScript explains function binding →

Also covered in

What to know first

Related concepts

Questions about function binding

What is function binding?

Function binding is the creation of a function with a predetermined this value and, optionally, preset arguments.

Which Manning books explain function binding?

Functional Programming in JavaScript and The Joy of JavaScript.

What should I know before learning function binding?

Manning books that teach function binding usually introduce function, this and arrow function first.

What is the difference between function binding and arrow function?

Function binding is the creation of a function with a predetermined this value and, optionally, preset arguments. An arrow function is a JavaScript function expression written with arrow syntax that uses lexical binding for this and has no own arguments object.

What is function binding also called?

Function binding is also called bind.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.