Create Arrays in JavaScript
JavaScript·2 min read·Jan 14, 2026
In JavaScript, arrays are resizable structures that can contain a mix of different data types ordered in a sequence.
Array literals are created using square brackets []:
array = [element1, ..., elementN];Where:
element1, ..., elementNare a list of optional values or variables separated by a comma character (,).
📚 In JavaScript, the value contained in an array is referred to as an element.
Example
In this example, the array assigned to the todo variable contains 0 elements:
let todo = [];In this example, the array assigned to the grades variable contains 4 integer elements:
let grades = [3, 8, 7, 6];Unlock the program 🚀
Pay once, own it forever.
€79
30-day money-back guarantee
- 13 modules
- 113 lessons with full-code examples
- 29 projects with commented solutions
- All future lesson and project updates
- Lifetime access
By submitting this form, you agree to the Terms & Conditions and Privacy Policy.