Last active
August 29, 2015 14:09
-
-
Save Veejay/eb4b51775b8095a6b6a0 to your computer and use it in GitHub Desktop.
Two functions on Object.prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since Object has
Object.keys(object)
, maybe it should beObject.values(object)
instead?