Skip to content

Instantly share code, notes, and snippets.

@ardeshireshghi
Created December 22, 2016 17:25
Show Gist options
  • Save ardeshireshghi/a372a103a50b602e4efdb691a48c61ad to your computer and use it in GitHub Desktop.
Save ardeshireshghi/a372a103a50b602e4efdb691a48c61ad to your computer and use it in GitHub Desktop.
Added some of the dict python api to JS Object type
;((Object) => {
Object.prototype.keys = Object.prototype.keys || function() {
return Object.keys(this);
}
Object.prototype.values = Object.prototype.values || function() {
return this.keys().map(key => this[key]);
}
Object.prototype.items = Object.prototype.items || function() {
return this.keys().map((key) => {
return [key, this[key]];
});
}
})(Object);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment