1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Fix expected result of immutable remove operation

This commit is contained in:
Nuno Vieira
2020-07-30 14:25:15 +01:00
parent 82c1f872e0
commit 460473a87f

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.