Skip to content

Instantly share code, notes, and snippets.

@st98
Created January 25, 2014 17:14
Show Gist options
  • Select an option

  • Save st98/8619785 to your computer and use it in GitHub Desktop.

Select an option

Save st98/8619785 to your computer and use it in GitHub Desktop.
自分用。
var partition = function (coll, n) {
var i = 0, j;
var len = Math.floor(coll.length / n);
var result = [], res;
for (; i < len; i++) {
res = [];
for (j = 0; j < n; j++) {
res.push(coll[i * n + j])
}
result.push(res);
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment