Array
An Array is a collection of data and a data structure that is stored in a sequence of memory locations. One can access the elements of an array by calling the index number such as 0, 1, 2, 3, …, etc. The array can store data types like Integer, Float, String, and Boolean all the primitive data types can be stored in an array.
Example: In this example, we will see the basic creation of a JavaScript Array and access the values of the array.
Javascript
let Arr = [1, 2, 3, 4, 5]; // Iterating through loop for (let i = 0; i < Arr.length; i++) { console.log(Arr[i]); } // Pop an element from array Arr.pop(); console.log( "After using pop() Method: " + Arr); |
1 2 3 4 5 After using pop() Method: 1,2,3,4