how to get key of an object code example
Example 1: get first object key javascript
var example = {
foo1: { },
foo2: { },
foo3: { }
};
let [first] = Object.keys(example)
console.log(first)
Example 2: js get object keys
myObject = {
"key": "value"
}
Object.keys(myObject);
Example 3: get all keys of object in javascript
myObject = {
"key": "value",
"key2":"value2"
}
Object.keys(myObject);
Example 4: get keys of object js
var buttons = {
foo: 'bar',
fiz: 'buz'
};
for ( var property in buttons ) {
console.log( property );
}