title: Lodash .clone and .cloneDeep behaviors
body: <p>I try to clone an array of objects with nested objects.</p>
  
  <p>Something like:</p>
  
  <pre><code>var data = [
      { id: 1, values: { a: 'a', b: 'b' } },
      { id: 2, values: { c: 'c', d: 'd' } }
  ];
  </code></pre>
  
  <h1>_.Clone</h1>
  
  <p>With the <a href="http://lodash.com/docs#clone" rel="noreferrer"><code>_.clone</code></a> method and the <code>isDeep</code> parameter at <code>true</code>:</p>
  
  <pre><code>var clone = _.clone(data, true);
  
  data[1].values.d = 'x';
  
  console.log( _.isEqual(data, clone) ); // true, clone[1].values.d == 'x'
  </code></pre>
  
  <p>I expected <code>clone[1].values.d == 'd'</code> :</p>
  
  <blockquote>
    <p>If isDeep is true nested objects will also be cloned, otherwise they
    will be assigned by reference.</p>
  </blockquote>
  
  <p>What is wrong?</p>
  
  <h1>_.CloneDeep</h1>
  
  <p>In addition, when I try with the <a href="http://lodash.com/docs#cloneDeep" rel="noreferrer"><code>_.cloneDeep</code></a> method, I get an error:</p>
  
  <pre><code>var clone = _.cloneDeep(data);
  
  // Uncaught TypeError: Object function u(n){return n instanceof u?n:new o(n)}
  // has no method 'cloneDeep'
  </code></pre>
  
  <p>Why this error?</p>
  
  <h1>$.extend</h1>
  
  <p>With <a href="http://api.jquery.com/jquery.extend/" rel="noreferrer"><code>$.extend</code></a> the clone has no reference to the original object as expected:</p>
  
  <pre><code>var clone = $.extend(true, {}, data);
  
  console.log( _.isEqual(data, clone) ); // false, clone[1].values.d == 'd' 
  </code></pre>