array matrix js code example Example: creating 2d array in javascript var [r, c] = [5, 5]; var m = Array(r).fill().map(()=>Array(c).fill(0));