Array Methods
push and pop work at the end, unshift and shift at the start. indexOf, includes and find search. slice copies a part without changing the array, while splice removes or inserts items and does change it.
join turns an array into a string, and concat or spread joins arrays.
Example
const items = ["a", "b", "c"];
items.push("d");
items.unshift("z");
console.log(items);
console.log(items.pop(), items.shift());
console.log(items.indexOf("b"), items.includes("q"));
console.log(items.slice(1));
items.splice(1, 1);
console.log(items.join("-"));Exercise
Add an item to the end.
list.("x");
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.