Skip to content

Instantly share code, notes, and snippets.

@fengjunren
Created November 4, 2022 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengjunren/f4c3fbd0d33dcb16fded6b656cda1da3 to your computer and use it in GitHub Desktop.
Save fengjunren/f4c3fbd0d33dcb16fded6b656cda1da3 to your computer and use it in GitHub Desktop.
[title]数组分组#js
function group(array, subNum) {
let index = 0;
let newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, (index += subNum)));
}
return newArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment