title: Making a new instance of a json javascript class?
body: <p>I've started writing a lot more javascript lately and am trying to do it all in the best way I can. Formatting my classes using JSON seems to be the cleanest way but I'm having trouble with something that seems like it should be really basic, but I just struggle to find the answer anywhere... perhaps merely from a lack of the right jargon!</p>
  
  <p>So far I've been doing things in this method:</p>
  
  <pre><code>function foo(){
     this.bar = 'hello world';
     this.init = function(){
        alert('this.bar');
     }
  }
  
  crow = new foo();
  crow.init();
  </code></pre>
  
  <p>And that all seems to work as I expect it to. When I lay out the object in JSON though I can't see to create a new instance of it, only a reference to the original which defeats the point of a lot of uses for me. What am I doing wrong here?</p>
  
  <pre><code>foo = {
     bar = 'hello world';
  
     init:   function(){
        alert(bar);
     }
  
  }
  
  foo.bar(); // This alerts 'hello world'
  
  crow = foo ;
  crow.bar = 'metal' ;
  crow.init(); // Outputs 'metal'
  foo.init(); // Also outputs 'metal'
  </code></pre>
  
  <p>Have I missed the point somewhere, is this the wrong approach or am I just doing it wrong?</p>