The Definitive Guide (6ed) error?
<pre><code>/*
* Copy the enumerable properties of p to o, and return o.
* If o and p have a property by the same name, o's property is overwritten.
* This function does not handle getters and setters or copy attributes.
*/
 function extend(o, p) {
       for(prop in p) { // For all props in p.
           o[prop] = p[prop]; // Add the property to o.
      }
      return o;
}



/*
* Return a new object that holds the properties of both o and p.
* If o and p have properties by the same name, the values from o are used.
*/
     function union(o,p) { return extend(extend({},o), p); }
</code></pre>

<p>I think for <strong>union</strong>, he meant "values from p are used".</p>

<p>I did the test on Chrome. Am I wrong? Sorry. I tend to be very caution when I am learning, especially this is the #1 book for Javascript, and 6ed is recent. </p>

<blockquote>
  <p>var o = {x:1}</p>
  
  <p>var p = {x: 2}</p>
  
  <p>function extend(o,p){</p>

<pre><code>for(prop in p)
    o[prop] = p[prop];
return o;
</code></pre>
  
  <p>}</p>
  
  <p>function union(o,p){</p>

<pre><code>return extend(extend({},o),p);
</code></pre>
  
  <p>var g = union(o,p)</p>
  
  <p>g.x</p>
  
  <p>2</p>
</blockquote>

<p>Thank you.</p>
