slice, splice and concat
slice copies a part without changing the array. splice removes or inserts items in place. concat and spread join arrays.
Example
const a = [1, 2, 3, 4, 5];
console.log(a.slice(1, 3), a);
const removed = a.splice(1, 2, "x");
console.log(removed, a);
console.log([1].concat([2], [3]), [...[1], ...[2]]);Exercise
Remove 2 items from index 1.
a.splice(1, )
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.