Skip to content

Instantly share code, notes, and snippets.

@getify
Created June 4, 2013 05:59
Show Gist options
  • Save getify/5703893 to your computer and use it in GitHub Desktop.
Save getify/5703893 to your computer and use it in GitHub Desktop.
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