title: Javascript - Cannot instantiate multiple instances of the same object
body: <p>I am trying to instantiate multiple instances of the same object. The first instantiation works fine, but when I try to initialize another object, I get this error,</p>
  
  <p><code>Uncaught TypeError: Object #&lt;draw&gt; has no method 'width'</code></p>
  
  <p>here is the <a href="http://jsfiddle.net/Odyss3us/GB4JM/" rel="nofollow">fiddle</a>, and here is my code:</p>
  
  <pre><code>function halo() {
    var width = 720, // default width
        height = 80; // default height
  
    function draw() {
      // main code
      console.log("MAIN");
    }
  
    draw.width = function(value) {
      if (!arguments.length) return width;
      width = value;
      return draw;
    };
  
    draw.height = function(value) {
      if (!arguments.length) return height;
      height = value;
      return draw;
    };
  
    return draw;
  }
  
  var halo = new halo();
  halo.width(500);
  
  var halo2 = new halo();
  halo2.width(300);
  </code></pre>
  
  <p>In summary, my objective is to instantiate multiple instances of the same "class".</p>