title: Deep copying array of nested objects in javascript
body: <p>I am trying to deep copy array of nested objects in javascript. My array look like this </p>
  
  <pre><code>var arr = [{name:"adam",age:"21"},
      {name:"freddie",age:"35",children:[{name:"mercury",age:"25"}]},
      {name:"jim",age:"35",children:[{name:"morrison",age:"25",children:[{name:"some", age:"40"}]}]}
      ];
  </code></pre>
  
  <p>I want to make a deep copy of every object inside the array that is i want to create a exact copy of arr into new array which should not have object reference. Depth of array is also unknown that is children array can be upto any level.
  I have gone through this link
  <a href="https://stackoverflow.com/questions/9885821/copying-of-an-array-of-objects-to-another-array-without-object-reference-in-java">Copying of an array of objects to another Array without object reference in javascript(Deep copy)</a> but that did not help me. I googled and found some solutions in jQuery but that did not help me as i dont have knowledge of jQuery.</p>
  
  <p>I also tried implementing it with recursion but that's not working too 
  <a href="http://ideone.com/kJi5X3" rel="noreferrer">http://ideone.com/kJi5X3</a></p>
  
  <p>I want to do it in javascript only without using jQuery or anything. I am new to JavaScript so i may have missed if there is any library or simple method to do this.
  Please help me to solve this problem. Thanks in advance.</p>