Skip to content

Instantly share code, notes, and snippets.

@Cside
Created March 20, 2012 11:49
Show Gist options
  • Select an option

  • Save Cside/2134430 to your computer and use it in GitHub Desktop.

Select an option

Save Cside/2134430 to your computer and use it in GitHub Desktop.
Object.keys(), Object.values()
Object.prototype.keys = function (i) {
var keys = Object.keys(this);
return (i >= 0) ? keys[i] : keys;
};
Object.prototype.values = function (i) {
var self = this;
var values = Object.keys(this).map(function(key){
return self[key];
});
return (i >= 0) ? values[i] : values;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment