Example 1 — Official: Flatten from the Right
Concat nested arrays starting at the last pair.
var array = [[0, 1], [2, 3], [4, 5]];
_.reduceRight(array, function (flattened, other) {
return flattened.concat(other);
}, []);
// → [4, 5, 2, 3, 0, 1] How It Works
- Seed. Start with
[]. - Last pair first. Concat
[4, 5]. - Then middle. Append
[2, 3]. - Then first. Append
[0, 1]→ final order ends with the left pair.

