Cartesian product of javascript object properties
问题 I have an object of the following form (simplified test case below) var test = { shirts: { sizes: ['large', 'medium'] ,colors:['red', 'blue'] } , trousers: { type: ['formal', 'casual'] , pattern: ['plaid', 'stripes'] } }; I want to generate a cartesian product of the properties so that the output is an array of the following form: // desired output [ {shirts:{sizes:'large', color:'red'}, trousers:{type:'formal', pattern:'plaid'}} ,{shirts:{sizes:'large', color:'red'}, trousers:{type:'formal',