Skip to content

Instantly share code, notes, and snippets.

@munierujp
Last active February 17, 2025 09:06
Show Gist options
  • Save munierujp/5eab2e66b972e6fa68be55206a15852b to your computer and use it in GitHub Desktop.
Save munierujp/5eab2e66b972e6fa68be55206a15852b to your computer and use it in GitHub Desktop.
const array1: number[] = [1, 2, 3]
const array2: boolean[] = [false, true]
const array3 = array1.flatMap(a => array2.map(b => [a, b] as const))
/*
type: (readonly [number, boolean])[]
value:
[
[ 1, false ],
[ 1, true ],
[ 2, false ],
[ 2, true ],
[ 3, false ],
[ 3, true ]
]
*/
console.log(array3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment