title: Get all the combinations of N elements of multidimensional array
body: <p>I'm trying to write an algorithm to get all the possible combinations of N elements inside a multi dimensional array of M elements.</p>
  
  <p>Something like:</p>
  
  <pre><code>function getCombinations(arr, n){
    ...
  }
  
  var arr = [ ["A"],["B","C"],["D","E"]];
  var n = 2;
  
  getCombinations(arr,n);
  </code></pre>
  
  <p>This should produce:</p>
  
  <pre><code>[
  ["A","B"],["A","C"],["A","D"],["A","E"],
  ["B","D"],["B","E"],
  ["C","D"],["C","E"]
  ]
  </code></pre>
  
  <p>The number of elements inside the array may vary, the only thing set is the number of elements of the combinations.</p>
  
  <p>The order doesn't matter but you cannot repeat, I mean <code>["A","B"] == ["B","A"]</code>, so the second one is not take in consideration.</p>
  
  <p>Any help? </p>