Open this example in the interactive library
Source code
console.log(
[1, 2, 3].reduce(
(sets, x) => sets.concat(sets.map((s) => [...s, x])),
[[]],
),
);
Sample output
[ [], [ 1 ], [ 2 ], [ 1, 2 ], [ 3 ], [ 1, 3 ], [ 2, 3 ], [ 1, 2, 3 ] ]
