JavaScript - List the properties of an object
Posted: 14 Jan 2015, 09:10
I have an object like this in javascript:
What is the best way to retrieve a list of the property names?
I would like to end up with some variable 'props' such that:
Code: Select all
var obj = {
prop1: 'val 1',
prop2: 'val 2',
prop3: 'val 3'
};
I would like to end up with some variable 'props' such that:
Code: Select all
props == ['prop1', 'prop2', 'prop3']