how to get object field name in javascript code example
Example 1: javascript list object properties
var person={"first_name":"Bill","last_name":"Jenner"}
//get the person object properties with:
var keys = Object.keys(person); //keys = ["first_name","last_name"]
Example 2: get object name javascript
var a = {
name:'a',
'light': 'good',
'dark' : {
name: 'dark',
'black': 'bad',
'gray' : 'not so bad'
}
}
// This way you can do
console.log(a.name,a.dark.name);