SOURCE

// 转置矩阵
    function transposition (array = []) {
        var baseLen = array.length;
        var len = array[0].length;
        return new Array(len).fill(undefined).map((a, aIndex) => {
            return new Array(baseLen).fill(undefined).map((b, index) => {
                return array[index][aIndex];
            });
        });
    }
    var resultA = transposition([
        [1, 2, 3],
        [4, 5, 6]
    ]);
    var result = [
        [1, 4],
        [2, 5],
        [3, 6]
    ];
    console.log(resultA);
console 命令行工具 X clear

                    
>
console