Created: 2022-10-23
pop.() to remove and save that item into a variable
const cities = ['Manchester', 'Liverpool'];
const removedCity = cities.pop();
console.log(removedCity); // "Liverpool"
const cities = ['Manchester', 'Liverpool'];
cities.shift();
In this call to splice(), takes two arguments
const cities = ['Manchester', 'Liverpool', 'Edinburgh', 'Carlisle'];
const index = cities.indexOf('Liverpool');
if (index !== -1) {
cities.splice(index, 2);
}
console.log(cities); // [ "Manchester", "Carlisle" ]