How do I clone a JavaScript class instance?
<p>How do I clone a JavaScript class instance?</p>

<p>I tried the normal jQuery extend, but that just returns a vanilla object. I have looked through many other answers on stack, but could not find how to clone an instance.</p>

<pre><code>function Parent(name) {
    this.name = name;
}

Parent.prototype.sayHello = function() {
    console.log('Hello my name is ' + this.name);
}

function Child(name) {
    Parent.call(this, name);
}

Child.prototype = Object.create(Parent.prototype);

var child = new Child('Billy');

var clone = $.extend(true, {}, child);
clone.name = 'Bob';

child.sayHello();
clone.sayHello();

console.log(child instanceof Child);
console.log(clone instanceof Child);
</code></pre>

<p><a href="http://jsfiddle.net/39gjA/">http://jsfiddle.net/39gjA/</a></p>

<p>I would prefer that the clone was deep/recursive. I.E. all properties that are objects are cloned as well.</p>
