Answers for "access first object property in js"

17

js get first object value

var obj = { first: 'someVal' };
obj[Object.keys(obj)[0]]; //returns 'someVal'
Posted by: Guest on November-03-2020
0

select the first property in an object

let obj = {
first: 'first property value',
second: "hello"};
obj[Object.keys(obj)[0]]; //returns 'first property value'
Posted by: Guest on December-08-2021

Code answers related to "access first object property in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language