JavaScript 实现chunk数组分组
function chunk(arr, size = 2) { var final = []; for(var i = 0, len = arr.length; i < len; i += size) { final.push(arr.slice(i, i + size)); } return final; }
欢迎转载,转载时请注明来源。
function chunk(arr, size = 2) { var final = []; for(var i = 0, len = arr.length; i < len; i += size) { final.push(arr.slice(i, i + size)); } return final; }