underscore.js _.zip[Array]
2012-04-15 23:30
323 查看
Merges together the values of each of the arrays with the values at the corresponding position. Useful when you have separate data sources that are coordinated through matching array indexes. If you're working with a matrix of nested arrays, zip.applycan transpose the matrix in a similar fashion
将相对应位置的数组的值合并到一起
源码:
将相对应位置的数组的值合并到一起
_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); => [["moe", 30, true], ["larry", 40, false], ["curly", 50, false]]
源码:
_.zip = function() { var args = slice.call(arguments); var length = _.max(_.pluck(args, 'length')); var results = new Array(length); for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i); return results; };
相关文章推荐
- underscore.js _uniq[Array]
- underscore.js _indexOf[Array]
- underscore.js _.lastIndexOf[Array]
- underscore.js _range[Array]
- underscore.js _.first[Array]
- underscore.js _.initial[Array]
- underscore.js _last[Array]
- underscore.js _reset[Array]
- underscore.js _.flatten[Array]
- underscore.js _without [Array]
- underscore.js _.union[Array]
- underscore.js _.intersect[Array]
- underscore.js _.difference[Array]
- underscorejs-indexBy学习
- underscore.js _.isEmpty(Object)
- underscore.js _isUndefined[Object]
- JS中判断相等的方法(underscore中eq方法源码分析)
- underscore.js
- underscore.js 中的 template 用法
- underscore.js