Created
June 17, 2009 18:09
-
-
Save silentmatt/131398 to your computer and use it in GitHub Desktop.
easily create multidimensional arrays in JavaScript
This file contains hidden or 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
function createArray(length) { | |
var a = new Array(Number(length) || 0); | |
if (arguments.length > 1) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
for (var i = 0; i < length; i++) { | |
a[i] = createArray.apply(this, args); | |
} | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment