Languages
[Edit]
EN

JavaScript - create array

3 points
Created by:
lena
714

This article will show you how to create an array in JavaScript.

Quick solution:

 

Practical examples

Edit

 The above creation of an array can also be written as follows:

 or:

Note: this approach will cause automatic array resizing on assigning new indexes - by assigning non consecutive indexes, the array will be filled in unused areas with null values.

or:

Note: this approach allocates necessary array space during array creation - not necessary resize in memory later.

or:

Note: the constructor-based approach used a much less frequent approach.

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - Arrays (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join