Skip to content

Instantly share code, notes, and snippets.

@hkan
Created Jun 13, 2014
Embed
What would you like to do?
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