Prototype chain in Javascript not updated
问题 I'm trying to understand prototypal inheritance in Javascript, but failing to apply to the following case. Any help would be appreciated. I'm defining a constructor as follows: var base = function() { var priv = "private"; // Private var publ = "public"; // Public through a getter/setter (below) // The object to return var f = {}; f.publ = function (new_val) { if (!arguments.length) { return publ; } publ = new_val; return f; }; return f; }; With this constructor, I can create objects by