Example 1 — Official: Depth 2
Triple-wrap each number; peel two layers.
function duplicate(n) {
return [[[n, n]]];
}
_.flatMapDepth([1, 2], duplicate, 2);
// → [[1, 1], [2, 2]] How It Works
- Iteratee. Each value becomes
[[[n, n]]]— three layers. - Map. Builds a nested array of those wrappers.
- Depth 2. Two flatten passes leave the inner pairs.
- Result.
[[1,1],[2,2]]— not fully flat yet.

