Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

creating a 2d array in js

var x = new Array(10);

for (var i = 0; i < x.length; i++) {
  x[i] = new Array(3);
}

console.log(x);
Comment

javascriopt initialize 2d array with size

function makeArray(w, h, val) {
    var arr = [];
    for(let i = 0; i < h; i++) {
        arr[i] = [];
        for(let j = 0; j < w; j++) {
            arr[i][j] = val;
        }
    }
    return arr;
}
Comment

creating 2d array in javascript

var [r, c] = [5, 5]; 
var m = Array(r).fill().map(()=>Array(c).fill(0));
Comment

js initialize 2d array

let data = [];
for (let row=0; row<rows; row++) {
    data.push(new Array(cols).fill('#'));
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: js redux example 
Javascript :: get window height javascript 
Javascript :: name first letter uppercase 
Javascript :: nuxt get client windows size 
Javascript :: proxy api javascript get 
Javascript :: document.queryselector 
Javascript :: how to do jest unit test in react 
Javascript :: json to csv javascript 
Javascript :: vs code file nesting 
Javascript :: javascript unshift 
Javascript :: change the color of toast toastr js 
Javascript :: javascript combining arrays 
Javascript :: event after div created 
Javascript :: clearinterval in javascript 
Javascript :: insert isValidPhoneNumber in react hook form 
Javascript :: import react js video player 
Javascript :: flatten nested object 
Javascript :: working of timers in javascript 
Javascript :: attr.disabled not working in angular 
Javascript :: react navbar material ui 
Javascript :: current page number and clicked page number jqery datatables 
Javascript :: javascript swap 
Javascript :: node js express session expiration 
Javascript :: Automatic Slideshow in react js 
Javascript :: shuffle array 
Javascript :: convert json to excel in javascript 
Javascript :: javascript compare number 
Javascript :: form contact 7 ajax send 
Javascript :: how to make a discord bot send a message 
Javascript :: react testing library 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =