Created
June 4, 2013 05:59
-
-
Save getify/5703893 to your computer and use it in GitHub Desktop.
Object.values
This file contains 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
// 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