Creating an array…
var fruits = ["mango", "orange", "apple"];
How to select any item from an array
You can access array data with indexes. The index number is written in a square bracket and it starts from 0 i.e 0 is the first element.
Let’s see an example…
let fruits = ["mango", "orange", "apple"]; let myFruits = fruits; alert(myFruits);
The index number  will select the first fruit in the array which is “mango”. This would be the output of the alert pop-up.
How to remove the last element from an array
let scores = [27, 46, 75]; alert(scores); //check pop up to see the array data //remove the last element from the array let changeLastScore = scores.pop(); alert(scores);
The last score on the data set which is “75” has been removed from the array.
When one of the elements of an array is another array, it is called a nested array.
let classes = [["Quantum Physics ", 16], [" Modern Biology ", 9], [" Robotics ", 4]];
To remove the last element of any of the nested arrays we just have to select the data set using an index number and then use the pop() function.
For example, we are going to remove the number from the last element of the nested array which is “4”.
let classes = [["Quantum Physics ", 16], [" Modern Biology ", 9], [" Robotics ", 4]]; alert(classes); let removeRoboticsNumber= classes.pop(); alert(classes);
Try with various examples to master the code. You can create a shopping list that would consist of nested arrays and then try to remove the last element from each nested array.