Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to create two dimensional array in js

const m = 4;
const  n = 5;
let arr = new Array(m); // create an empty array of length n
for (var i = 0; i < m; i++) {
  arr[i] = new Array(n); // make each element an array
}
console.log(arr); //  Output: [ [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ], [ <5 empty items> ] ]
Source by www.w3docs.com #
 
PREVIOUS NEXT
Tagged: #create #dimensional #array #js
ADD COMMENT
Topic
Name
5+4 =