Javascript - Cannot instantiate multiple instances of the same object

bethmule

New Member
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,\[code\]Uncaught TypeError: Object #<draw> has no method 'width'\[/code\]here is the fiddle, and here is my code:\[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\]In summary, my objective is to instantiate multiple instances of the same "class".
 
Back
Top