Overview
JavaScript is becoming ever increasingly more popular as time goes by. While JavaScript has many advantages, it also has many interesting quirks or nuances that can catch out new beginners.
In this post I’ll show you how to deep clone a JavaScript object.
Problem
Okay … before we go any further … lets take a step back and understand the problem at hand.
Objects in JavaScript are passed by reference, meaning that any object returned by a function will point to the same memory reference as the original object. Therefore if the caller of the function modifies the returned object, they will actually be changing the original source object.