JavaScript - Generating combinations from n arrays with m elements
问题 I'm having trouble coming up with code to generate combinations from n number of arrays with m number of elements in them, in JavaScript. I've seen similar questions about this for other languages, but the answers incorporate syntactic or library magic that I'm unsure how to translate. Consider this data: [[0,1], [0,1,2,3], [0,1,2]] 3 arrays, with a different number of elements in them. What I want to do is get all combinations by combining an item from each array. For example: 0,0,0 // item