Method chaining

Each method returns an object, allowing the calls to be chained together in a single statement without requiring variables to store the intermediate results.

[2] Method chaining eliminates an extra variable for each intermediate step.

Cascading is a key technique in fluent interfaces, and since chaining is widely implemented in object-oriented languages while cascading isn't, this form of "cascading-by-chaining by returning this" is often referred to simply as "chaining".

A common example is iostream in C++, where for example << returns the left object, allowing chaining.

Compare: equivalent to: Another example in JavaScript uses the built-in methods of Array: Note that in JavaScript filter and map return a new shallow copy of the preceding array but sort operates in place.