title: How to generate new instances of an object without the class?
body: <h1>Question:</h1>
  
  <p>How can I generate new instances of a class from an instance of that class?</p>
  
  <h1>What I've found:</h1>
  
  <p>Consider the next class and its instance:</p>
  
  <pre><code>// Create a new class
  var Foo = function Foo () {
    console.log('New instance of FOO!');
  };
  
  Foo.prototype.generate = function(first_argument) {
    this.arr = [1,2,3,4,5];
  };
  
  var foo = new Foo();
  
  foo.generate();
  console.log(foo.arr); // [1,2,3,4,5]
  </code></pre>
  
  <p><strong>Note that <code>foo</code> is as an instance fo <code>Foo</code>, and i'll be using this instance in the examples.</strong></p>
  
  <h2>Object.create</h2>
  
  <p>With Object.create I can generate new copies of the foo instance, but they will share the state data:</p>
  
  <pre><code>var bar = Object.create(foo);
  console.log(bar.arr); // [1,2,3,4,5]
  
  bar.arr.push(6);
  console.log(foo.arr); // [1,2,3,4,5,6]
  console.log(bar.arr); // [1,2,3,4,5,6]
  </code></pre>
  
  <p>And if some logic is in the constructor it is not called.</p>
  
  <h2>Prototype inheitance</h2>
  
  <p>This is similar to the object create but it calls the constructor. It still has the same state data problem:</p>
  
  <pre><code>var Bar = function () {
    foo.constructor.call(this);
  };
  
  Bar.prototype = foo;
  
  var bar = new Bar();
  console.log(bar.arr); // [1,2,3,4,5]
  
  bar.arr.push(6);
  console.log(foo.arr); // [1,2,3,4,5,6]
  console.log(bar.arr); // [1,2,3,4,5,6]
  </code></pre>
  
  <h2>Firefox proto</h2>
  
  <p>Here is an example of what I exactly want to do, but it only works in Firefox:</p>
  
  <pre><code>// Create Bar class from foo
  var Bar = foo.constructor;
  Bar.prototype = foo.__proto__; // Firefox only
  </code></pre>
  
  <p>Here I have the class Bar that's a copy of the class Foo and I can generate new instances.</p>
  
  <pre><code>var bar = new Bar();
  
  console.log(bar.arr); // undefined
  
  bar.generate();
  console.log(bar.arr); // [1,2,3,4,5]
  </code></pre>
  
  <p>Is there any other way to achive the same goal that works in all the browsers?</p>