Flattening
We'll cover the following...
Flattening streams
Flattening arrays
You may have heard of a flatten
function.
flatten
functions take an input of some sort and “unwrap” it. (In this case, unwrapping an array is to pull out the elements in the array and use those.)
This hypothetical code snippet returns [2, 4, 7, 12]
:
flatten([[2], [4, 7], 12])
Usually, a single call to flatten only unwraps by one layer.
Flattening promises and observables
Flatten iterates through the array, unwrapping ...