Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Javascript sugar: get your keys or values of an object
//lo sauer '12
var o={a: 1, b: 2, c: 3},k
//#1 method
for(k[k.length] in k=[],o); //keys
//> ["a", "b", "c"]
#2 elegant
//> ["a", "b", "c", "i", "length"]
//>["c", "length", "i", "b", "a"]
//to get values no sugar-version exists
var v=[]
for(var i in o)v.push(o[i]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.