cartesianProduct
Computes the Cartesian product of the provided arrays.
Returns all possible tuples formed by picking one element from each input array, in lexicographic order relative to the input order.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
arrays | T | Two or more arrays to combine. |
Returns
Section titled “Returns”mapped[] — An array of tuples, each containing one element from each input array.
Examples
Section titled “Examples”Combine two arrays
Section titled “Combine two arrays”Returns all ordered pairs from two arrays.
Generate product combinations
Section titled “Generate product combinations”Useful for generating all size/color variant combinations.
Empty input returns empty array
Section titled “Empty input returns empty array”If any input array is empty, the result is an empty array.
