Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 766 Bytes

File metadata and controls

24 lines (16 loc) · 766 Bytes

Remove Product from Array (JavaScript)

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.

💡 Use Case

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.

🚀 Features

  • Clone array using the spread operator (...)
  • Find item index with findIndex()
  • Remove item using splice() safely
  • Preserve original array

🧪 Example

removeProduct(3); 
// Removes Product with ID 3, returns new array

console.log(products);
// Original array remains unchanged