1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-10 18:48:02 +00:00

Compare commits

2 Commits

Author SHA1 Message Date
Nuno Vieira
53ec73c1ae Merge 460473a87f into 4ba53dca7d 2025-04-08 15:29:56 -05:00
Nuno Vieira
460473a87f Fix expected result of immutable remove operation 2020-07-30 14:32:08 +01:00

View File

@@ -15,10 +15,8 @@ const remove = (items,index) => {
};
const list = [1,2,3,4,5];
remove(list, 2);
// [1,2,3,4]
list
// [1,2,3,4,5]
remove(list, 2); // [1,2,4,5]
// list still [1,2,3,4,5]
```
It only took a couple lines of code and immutability is baked in.