Below is an ad-hoc example of something similar to what I’ve seen in the wild:
This technique is called chaining.
Arrays inherit Array methods through prototypal inheritance. If we have an Array [1,2,3], it inherits methods like .filter() and .map() and can be used like so:
Take for example this following code:
Alternatively, it could be written like this:
Now, let’s revisit the first set of code and break it down:
The following is a list of Array methods that will create new arrays when used. This is not a comprehensive list of chainable Array methods. Let me know if I missed anything.