Right way to use Prototypal Inheritance in JavaScript?
<p>Using Crockford's method ( <a href="http://javascript.crockford.com/prototypal.html" rel="nofollow">http://javascript.crockford.com/prototypal.html</a> ) doesn't work when we have reference values in properties (an array in the supertype) as this is common among all the objects.</p>

<p>So, what's really the recommended way to do object inheritance in Javascript that doesn't have problem and that visually encapsulates better all the object's methods and properties?</p>

<p>Example:</p>

<pre><code>if (typeof Object.create !== 'function') {
    Object.create = function (o) {
        function F() {}
        F.prototype = o;
        return new F();
    };
}
var p1 = {name: "nick", friends : ["a1", "a2"]};
var p2 = Object.create(p1);
p2.name ="john";
p2.friends.push("andre");
alert(p1.friends);
alert(p2.friends);
alert(p1.name);
alert(p2.name);
</code></pre>

<p>The friends array returns the same values for both p1 and p2, while I expect that it returns different values.</p>
