Arrays in Javascript
Arrays in Javascript
JAVASCRIPT
Creating Array in Javascript
An array is an object that can store multiple values at once. For example,
The easiest way to create an array is by using an array literal []. For example,
You can access elements of an array using indices (0, 1, 2 …). For example,
// first element
console.log(myArray[0]); // "h"
// second element
console.log(myArray[1]); // "e"
Array Properties
You can find the length of an element (the number of elements in an array)
using the length property. For example,
push() aads a new element to the end of an array and returns the new length of an array
unshift() adds a new element to the beginning of an array and returns the new length of an array
pop() removes the last element of an array and returns the removed element
shift() removes the first element of an array and returns the removed element
slice() selects the part of an array and returns the new array