JavaScript provides several methods to manipulate arrays, making it easier to work with lists of data.
let fruits = ["apple", "banana", "cherry"];
fruits.push("orange"); // Adds "orange"
fruits.pop(); // Removes last element
console.log(fruits);
Create an array of numbers. Use push
, pop
, shift
, and unshift
to manipulate the array.
push()
do?unshift()
do?Answers: Adds to end; shift(); adds to beginning.