Skip to content

Instantly share code, notes, and snippets.

@hkan
Created June 13, 2014 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkan/d1dd07d90fca48a908a9 to your computer and use it in GitHub Desktop.
Save hkan/d1dd07d90fca48a908a9 to your computer and use it in GitHub Desktop.
Object Prototype
Object.defineProperty(Object.prototype, "getDotNotated", {
value: function (dotNotation) {
var arrayOfNames = dotNotation.split('.');
var tmp = this;
for (var i in arrayOfNames) {
if (arrayOfNames.hasOwnProperty(i)) {
tmp = tmp[arrayOfNames[i]];
}
}
return tmp;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment