title: Replace one object's properties with the properties of another?
body: <p>First I am not saying deep cloning one object to another.</p>
  
  <p>I have one object:</p>
  
  <pre><code>var data1 = {
                 p1: values1,
                 p2: values2,
                 .....
              };
  </code></pre>
  
  <p>value1 and value2 can be any data type, like object or array.</p>
  
  <p>I have another object:</p>
  
  <pre><code>var data2 = {
                 p3: values3,
                 p4: values4,
                 .....
              };
  </code></pre>
  
  <p>value3 and value4 can be any data type, like object or array.</p>
  
  <p>Now I want to clone all data2's properties to data1.</p>
  
  <p>The reason I want this is data1 is referenced, after data1's properties are changed I don't want to breake the reference.</p>
  
  <p>If I do something like</p>
  
  <pre><code> data1 = clone(data2)
  </code></pre>
  
  <p>I will break the  reference.</p>
  
  <p>Update:
   What means by breaking the references:</p>
  
  <pre><code>var data1 = {
               p1: value1
            }; 
  var data2 = {
                p2: vale2
            };
  var ref = data1;
  </code></pre>
  
  <p>If I do:   </p>
  
  <pre><code>data1 = clone(data2);  
  </code></pre>
  
  <p>Now ref still point to the old data1, its value still be:</p>
  
  <pre><code>{
     p1: value1
  }
  </code></pre>
  
  <p>But I want ref be data2</p>