devxlogo

Multi-dimensional Arrays

Multi-dimensional Arrays

Question:
Can I create multi-dimensional arrays in JavaScript? Do you have an example?

Answer:
Yes and no.

You can’t create multi-dimensional arrays (as such) in JavaScript. What you can do is create an array of arrays, though.For instance, you can have:

numberArray = new Array("one","two","three")letterArray = new Array("a","b","c")bigArray = new Array(numberArray,letterArray)

You could later reference bigArray[0][1], which would be “b” (arrays are zero-relative).

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist