Sometimes, we want to declare an array in JavaScript.
In this article, we’ll look at how to declare an array in JavaScript.
How to declare an array in JavaScript?
To declare an array in JavaScript, we can use the array literal syntax.
For instance, we write
const x = [];
const y = [10];
to declare the empty array x
.
And we declare the array y
with 10 inside.
Conclusion
To declare an array in JavaScript, we can use the array literal syntax.