underscore.js: _.zip.apply example

后端 未结 2 695
北海茫月
北海茫月 2021-01-18 23:49

I would like to see an example of _.zip.apply using underscore.js.

In the underscore documentation is written:

If you\'re working

2条回答
  •  时光说笑
    2021-01-19 00:18

    You can use also a 'non-external-library' method:

    Create this function:

    function transpose(arr) {
            return Object.keys(arr[0]).map(function (c) {
                return arr.map(function (r) {
                    return r[c];
                });
            });
        }
    

    and then:

    var transposedArray = transpose(originalArray);

提交回复
热议问题