This mini JavaScript utility demonstrates how to remove an item from an array without mutating the original array, using the splice() method and spread operator.
In functional programming and real-world frontend apps (like React), it's essential to avoid mutating the original data. This project helps beginners understand how to clone arrays and perform safe modifications.
- Clone array using the spread operator (
...) - Find item index with
findIndex() - Remove item using
splice()safely - Preserve original array
removeProduct(3);
// Removes Product with ID 3, returns new array
console.log(products);
// Original array remains unchanged