Remove last item from array
Given an array of items, write a JavaScript program to remove the last item from the array.
Solution
To remove the last item from given array of items, call pop()
method on the given array object.
array1.pop()
removes the last item from the array array1
.
Programs
1. Remove first item from array array1
.
let array1 = ['apple', 'banana', 'cherry'];
array1.pop();
console.log(array1);