Tip 25 | Combine Methods with Chaining |
In this tip, you’ll learn to perform multiple array methods with chaining.
Chaining is an old concept in programming. You can find it in many object-oriented languages.[20] Like a lot of programming concepts, it actually sounds more complicated than it is in practice.
Here’s a quick definition: Chaining is immediately calling a method on a returned object (which in some cases is the original object) without reassigning the value first.
Okay, now forget that definition. For our purposes, chaining means that you can call several array methods in a row (as long as you get an array back). It’s a convenient way to perform several actions in a very clear manner.
Think back to the last example: sending notifications ...
Get Simplifying JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.