Immutable | Mutable |
---|---|
ages.map(x => x+1) | ages.push(8) |
ages.filter(x => x>21) | ages.sort |
ages.slice(1,2) | ages.splice(2,1,18) |
spread operator helps in achieving immutability.
TODO
- read more about how spread operator optimises for copying objects and arrays
Immutable | Mutable |
---|---|
ages.map(x => x+1) | ages.push(8) |
ages.filter(x => x>21) | ages.sort |
ages.slice(1,2) | ages.splice(2,1,18) |
spread operator helps in achieving immutability.