How to create a 2D array in JavaScript

Опубликовано: 19 Октябрь 2024
на канале: Read Write Exercise
29,809
317

JavaScript does not have built-in support two dimensional arrays. But just because are no standard library functions to create a two or multi-dimensional array doesn't mean it's not possible. Here are several different simple ways, from a one-liner to using for loops, to initialize a two dimensional array in JS.

📬 SUBSCRIBE:    / @readwriteexercise  

Code link: https://github.com/bradydowling/read-...

In this playlist
Part 1:    • How to Flatten an Array in JavaScript  
Part 2:    • How to remove an element from a JavaS...  
Part 3:    • How to check if a string contains a s...  
Part 4:    • Slice vs splice JavaScript array methods