What means x[] = [] in p5.js

hi!
im trying to translate some code from p5.js

var st = [];

function setup(){

for (var i=0; i<maxW; i++) {
		st[i]=[];   // what means this?
		bright[i]=[];
}

}

what means ? st is a two dimensional array!

2 Likes
  • The syntax [] creates an empty new Array.
  • st[i] = []; :arrow_right: creates an empty Array and then assign it to the Array st at its index i.
  • Thus, variable st (and also bright) is a 2D Array w/ maxW as the number of rows :arrow_right: st[maxW][].
2 Likes