Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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 :: jquery not readonly 
Javascript :: prime number in javascript 
Javascript :: how to remove first character from string in javascript 
Javascript :: apply css to iframe content javascript 
Javascript :: useref material ui 
Javascript :: from string to number js 
Javascript :: data down action up 
Javascript :: javascript on uncaught exception 
Javascript :: javascript object 
Javascript :: not disabled jquery 
Javascript :: how to use put to request in nodejs 
Javascript :: jquery validation focus field on error 
Javascript :: angular input type text character limit 
Javascript :: javascript await 
Javascript :: regrex match emails 
Javascript :: react native text style example 
Javascript :: how to get date in footer javascript 
Javascript :: ajax mdn 
Javascript :: compare two array in javascript 
Javascript :: jquery is emptyobjec 
Javascript :: $unset mongodb 
Javascript :: how to find out most repeated string in an array js 
Javascript :: tsconfig build only files and not src 
Javascript :: hide the js code from source 
Javascript :: angular socket.io with token header 
Javascript :: react using proptypes 
Javascript :: what is template engine in express 
Javascript :: innertext js 
Javascript :: jquerry get url 
Javascript :: jquery 3.6.0 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =