1 let array = ["A", "B", "C"];
2
3//Removes the last element of the array
4 array.pop();
5
6//===========================
7 console.log(array);
8//output =>
9//["A", "B"]
10
11//if you want to remove more varibles in the array,
12//insted of using push you can simply define the length of the array
13 let array1 = [1, 2, 3, 4, 5, 6];
14
15//Defines the length of the array to 2, removing the elements
16//after the second element
17 array1.length = 2;
18
19//===========================
20 console.log(array1);
21//output =>
22//["1", "2"]
23
1const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato'];
2
3console.log(plants.pop());
4// expected output: "tomato"
5
6console.log(plants);
7// expected output: Array ["broccoli", "cauliflower", "cabbage", "kale"]
1var array = ['A', 'B', 'C'];
2// removes and returns last element
3lastElement = array.pop();
1var cars = ['mazda', 'honda', 'tesla'];
2var telsa=cars.pop(); //cars is now just mazda,honda
1let animals = ["dog","cat","tiger"];
2
3animals.pop(); // ["dog","cat"]
4
5animals.push("elephant"); // ["dog","cat","elephant"]