What is an Array in JavaScript ?
Last Updated :
12 Feb, 2024
In JavaScript, an array is a data structure used to store multiple values of any data type sequentially. Arrays allow you to group together related data items under a single variable name. Each value in an array is called an element, and each element is accessed by its index, starting from 0.
Example: Here, the variable numbers
is assigned an array containing five numeric elements [1, 2, 3, 4, 5]
. The elements are enclosed within square brackets ([]
) and separated by commas. Each element has a numeric value, and they are stored sequentially in the array.
Javascript
let numbers = [1, 2, 3, 4, 5];
console.log(numbers);
|
Share your thoughts in the comments
Please Login to comment...