I have a JavaScript object like
var obj = { key1: \'value1\', key2: \'value2\', key3: \'value3\', key4: \'value4\' }
How can I
Underscore.js makes the transformation pretty clean:
var keys = _.map(x, function(v, k) { return k; });
Edit: I missed that you can do this too:
var keys = _.keys(x);