Popular this week 🔥
This is so insightful and informative ❤️
3
A great introduction to shallow vs deep cloning in JavaScript.
Be careful using JSON parse/stringify to deep clone as it does not support some JavaScript features when used to clone objects. Date objects will convert to strings. Functions, symbols, and undefined are also not correctly converted over.
Just a couple of things to watch out for if one is looking for a proper deep clone. Better off to use something like lodash cloneDeep for correctness and performance reasons.
6