> For the complete documentation index, see [llms.txt](https://demirels-organization.gitbook.io/javascript-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demirels-organization.gitbook.io/javascript-tutorial/arrays.md).

# Arrays

In JavaScript, an array is a data structure that stores a collection of elements. Elements in an array can be of any data type, such as numbers, strings, objects, or even other arrays.

Arrays are created using the literal notation array, square brackets \[] with elements separated by commas. For example:

```javascript
let myArray = [1, 2, 3, 4, 5];
```

OR

```javascript
let myArray = ["apple", "banana", "orange"];
```

Elements in an array can be accessed by their index, which is the position of the element in the array starting from 0. For example:

```javascript
console.log(myArray[0]); // Output: 1
console.log(myArray[1]); // Output: 2
```

JavaScript arrays also have built-in methods that can be used to manipulate the elements, such as push() to add an element to the end of the array, pop() to remove the last element, shift() to remove the first element, unshift() to add an element to the beginning of the array, and others.

JavaScript also has several array prototype methods, such as filter() and map() which are used for iterating over the array and applying a function to each element and returning the new array.

In short, Array is a data structure that stores multiple elements of the same or different types in a single variable. It is a powerful tool that allows you to organize and manipulate data in a convenient and efficient way.
