JavaScript Protected Properties
Imagine this simple piece of code: var obj = { _name: "protected", gimmeName: function () { return this._name; } }; obj.gimmeName(); // "protected" obj._name; // throws new Errror now, imagine I have the simplest solution ever, compatible with both ES5 and ES3 genric implementations ... now please keep reading to know a bit of background :) The JS Meaning Of Protected JS developers know that in JavaScript properties are always public and that it is possible to attach/detach properties in any moment to a generic object. Regardless this fact, many libraries consider protected, by naming convention, all those properties whose name start with "_" . You Are Doing It Wrong First of all I keep saying that is a common error trying to bring classical Object Oriented concepts into a completely different language as JavaScript is, but it does not matter ... we want protected stuff, right? Due dynamic nature, the common protected meaning is point...