2d-arrays
v1.0.1
Published
a node module which can get you 2d Array
Downloads
10
Maintainers
Readme
2d-Array
Create perfect 2d arrays in JavaScript without writing a custom js
for it.
let dArray = require("2d-arrays");
let x = dArray(2, 2, true);
// [[0,0],
// [0,1]]
dArray(arg1, arg2, arg3)
arg1 represents the n number of rows and arg2 represents the m numbers of coloumns. arg3 is an optional arguments.
Cases for arg3
// Case I - To initilize every element to undefined (by default)
dArray(4, 2);
// Output
[
[undefined, undefined],
[undefined, undefined],
[undefined, undefined],
[undefined, undefined],
];
// Case I - To initialize with index position the index numbers
dArray(4, 2, true);
// Output
[
["0,0", "0,1"],
["1,0", "1,1"],
["2,0", "2,1"],
["3,0", "3,1"],
];
// To initilize every element to null
dArray(4, 2, true);
// Output
[
[null, null],
[null, null],
[null, null],
[null, null],
];