Created
January 28, 2015 13:28
-
-
Save iptpv/f8ca0db895160c3bbf46 to your computer and use it in GitHub Desktop.
разбитие массива на определенное число массивов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [1, 2, 3, 4, 5, 6, 7, 8, 9], | |
columns = 3, | |
dataAr = []; | |
for (var colCount = 0, i = 0; colCount < data.length; colCount+=(data.length/columns), i++) { | |
dataAr[i] = data.slice(colCount, colCount + data.length/columns); | |
} | |
console.log(dataAr); | |
/** | |
* http://jsbin.com/jeqijolisa/1/ | |
* / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment