Why is my alternate version of a JavaScript Definitive Guide class example not working
<p>Its on pp 200-201 of Chapter 9 on Classes and Modules.  This approach below occured to me as being more straightforward, but the commented output lines below  are not working for unknown reasons:</p>

<pre><code>Range.prototype = {
  includes: function(x) {
    return this.from &lt;= x &amp;&amp; x &lt;= this.to;
  },

  foreach: function(f) {
    for (var x = Math.ceil(this.from); x &lt;= this.to; x++) f(x);
  },

  toString: function() {
    return "(" + this.from + "..." + this.to + ")";
  },

  Z: "ZZZZZZZZZZZZZZZZZZZ",    
}

function Range(from,to) {
  this.from = from
  this.to = to
}

var r = new Range(1,3)

console.log(Range.prototype.Z)
console.log(r.constructor.prototype.Z)  //undefined 
console.log(r.Z)
console.log(r.includes(2));
console.log(r.toString());
console.log(r);  // Does not use Range.toString 
r.foreach(console.log); // TypeError 
</code></pre>
