js get first object value
var obj = { first: 'someVal' };
obj[Object.keys(obj)[0]]; //returns 'someVal'
js get first object value
var obj = { first: 'someVal' };
obj[Object.keys(obj)[0]]; //returns 'someVal'
how to get the first key in a n object in javascript
var obj = { "a" : 1, "b" : 2, "c" : 3};
alert(Object.keys(obj)[0]);
// alerts "a"
let objLength = Object.keys(obj).length
console.log(objLength)
// Logs 3 as "obj" has 3 keys
var objValue = Object.values(obj)[0]
console.log(objValue)
// Logs "1" as the value of the first key(a) is "1"
javascript object first key
var person = {"name":"Steve","age":43};
var firstKeyValue = person[Object.keys(person)[0]]; //"Steve"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us