title: Transposing a 2D-array in JavaScript
body: <p>I've got an array of arrays, something like:</p>
  
  <pre><code>[
      [1,2,3],
      [1,2,3],
      [1,2,3],
  ]
  </code></pre>
  
  <p>I would like to transpose it to get the following array:</p>
  
  <pre><code>[
      [1,1,1],
      [2,2,2],
      [3,3,3],
  ]
  </code></pre>
  
  <p>It's not difficult to programmatically do so using loops:</p>
  
  <pre><code>function transposeArray(array, arrayLength){
      var newArray = [];
      for(var i = 0; i &lt; array.length; i++){
          newArray.push([]);
      };
  
      for(var i = 0; i &lt; array.length; i++){
          for(var j = 0; j &lt; arrayLength; j++){
              newArray[j].push(array[i][j]);
          };
      };
  
      return newArray;
  }
  </code></pre>
  
  <p>This, however, seems bulky, and I feel like there should be an easier way to do it. Is there?</p>