Skip to content

Instantly share code, notes, and snippets.

@getify
Created Jun 4, 2013
Embed
What would you like to do?
Object.values
// why doesn't this exist?
if (!Object.values) {
Object.values = function(obj) {
var i, ret = [];
for (i in obj) {
ret.push(obj[i]);
}
return ret;
};
}
var o = {
foo: "foo value",
bar: "bar value"
};
Object.keys(o); // ["foo","bar"]
Object.values(o); // ["foo value","bar value"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment