Skip to content

Instantly share code, notes, and snippets.

@Veejay Veejay/sugar.js
Last active Aug 29, 2015

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.