Skip to content

Instantly share code, notes, and snippets.

@Veejay
Last active August 29, 2015 14:09
Show Gist options
  • Save Veejay/eb4b51775b8095a6b6a0 to your computer and use it in GitHub Desktop.
Save Veejay/eb4b51775b8095a6b6a0 to your computer and use it in GitHub Desktop.
Two functions on Object.prototype
Object.prototype.values = function() {
return Object.getOwnPropertyNames(this).reduce(function(values, property) {
values.push(this[property]);
return values;
}.bind(this), []);
};
Object.prototype.forEach = function(callback) {
Object.keys(this).forEach(function(key) {
callback.call([], key, this[key]);
}.bind(this));
};
@Veejay
Copy link
Author

Veejay commented Nov 14, 2014

Since Object has Object.keys(object), maybe it should be Object.values(object) instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment