Arrays in JavaScript
Hey everyone! Today, we're diving into Arrays in JavaScript, one of the most fundamental and powerful data structures. Let's jump in and explore the different ways arrays can be used to store, manipulate, and access data!
What is an Array?
- An
arrayin JavaScript is a special type ofobjectused to store multiple values in a single variable. - Arrays can hold a collection of items, such as numbers, strings, objects, or even other arrays.
- Each element in an array is stored at a specific
index, starting from0, which allows for easy access and manipulation of the data.
Video Explanation

Key Features of Arrays:
- Arrays can hold values of different data types.
- They have a dynamic size, meaning elements can be added or removed.
- Elements are accessed via their
index, starting from0.
Example of an Array:
let fruits = ['apple', 'banana', 'cherry']; // array of fruits
console.log(fruits[0]); // Output: 'apple'
console.log(fruits[2]); // Output: 'cherry'
In this example, the array fruits contains three string elements, and we access the first and third items using their indices.