How do you declare a two-dimensional array in JavaScript?

  • let arr = [[]];
  • let arr = [][[]];
  • let arr = [[], []];
  • let arr = [[],] [[]];
In JavaScript, a two-dimensional array is declared by creating an array where each element is another array. This creates a matrix-like structure. For example, let arr = [[], []]; declares a 2x2 two-dimensional array. The other options contain syntax errors or do not create a valid two-dimensional array.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *