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.
Loading...
Related Quiz
- How is block scope affected when using var compared to let and const?
- Which keyword is used to check a condition in JavaScript?
- A ________ object represents a group of response headers, allowing you to query them and take different actions depending on the results.
- When using a do-while loop, the loop will always execute at least ________ time(s).
- An arrow function is defined using the _________ symbol.