function transpose_(arr, fillValue) {
  let transposed = [];
  arr.forEach(function(row, rowIndex) {
    row.forEach(function(col, colIndex) {
      transposed[colIndex] = transposed[colIndex] || fillArray_([], arr.length, fillValue);
      transposed[colIndex][rowIndex] = row[colIndex];
    });
  });
  return transposed;
}
Transposes a matrix/2d array. For cases where the rows are not the same length,
`fillValue` is used where no other value would otherwise be present.

@param {Array<Array<object>>} arr - 2D array to transpose
@param {object} fillValue - Placeholder for undefined values created as a result
    of the transpose. Only required if rows aren't all of equal length.
@return {Array<Array<object>>} New transposed array