Array handling in JS with functional purity
A convention has sprung up recently to make pure functions in Javascript. To get purity when dealing with arrays or objects cloning has been encouraged. But the nuance of Javascript and references is tricky. To get it right we need to understand references, mutations, shallow clones and deep clones. Which is quite a mouthful and is easy to trip over when coding.
TLDR
Know when we’re mutating to use shallow clones and avoid deep clones for internal functions.
Read more →