In contrast to variables array can store _multiple values_. Each value in an array has an _index_ and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_ and the last element is less by one from the length of the array.
In contrast to variables, an array can store _multiple values_. Each value in an array has an _index_, and each index has _a reference in a memory address_. Each value can be accessed by using their _indexes_. The index of an array starts from _zero_, and the last element is less by one from the length of the array.
Array is a collection of different data types which are ordered and changeable(modifiable). Allows duplicate element and different data types. An array can be empty or it may have different data type values
An array is a collection of different data types which are ordered and changeable(modifiable). An array allows storing duplicate elements and different data types. An array can be empty, or it may have different data type values.
### How to create an empty array
### How to create an empty array
In JavaScript we can create array in different ways. Let us different ways to create an array.
In JavaScript, we can create an array in different ways. Let us different ways to create an array.
- Using Array constructor
- Using Array constructor
@ -125,7 +125,7 @@ console.log(arr)
### Creating an array using split
### Creating an array using split
As we have seen in earlier section, we can split a string at different position and we can change to an array. Let us see the examples blow.
As we have seen in the earlier section, we can split a string at different positions, and we can change to an array. Let us see the examples below.
```js
```js
let js = 'JavaScript'
let js = 'JavaScript'
@ -148,7 +148,7 @@ console.log(words)
### Accessing array items using index
### Accessing array items using index
We access each element in an array using their index. An array index start from 0. The picture below show clearly the starting of the index.
We access each element in an array using their index. An array index starts from 0. The picture below clearly shows the starting of the index.
join:To join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default it joins with a comma but we can pass different string parameter which can be joined between the items.
join: It used to join the elements of the array, the argument passed in the join method will be joined in the array and return as a string. By default, it joins with a comma, but we can pass different string parameter which can be joined between the items.
sort: arrange array elements in ascending order. Sort takes a call back function, we wil see how we use sort with call back function in the coming sections.
sort: arrange array elements in ascending order. Sort takes a call back function, we will see how we use sort with call back function in the coming sections.