# 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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://demirels-organization.gitbook.io/javascript-tutorial/arrays.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
