Hi Friends đź‘‹,
Welcome To Infinitbility! ❤️
Today, we will learn to get the first value from a JSON object in javascript, here we will Object.values()
method to get the first value from the object.
What is Object.values()
The Object.values() method returns an array of a given object’s own enumerable property values, in the same order as that provided by a for…in the loop. (The only difference is that a for…in loop enumerates properties in the prototype chain as well.)
— MDN
The Object.values()
will return an only array of values available in an object, now we can easily get the first value from the JSON object using array 0th index.
let’s see how can do in javascript
1const domain = {2 name: "Infinitbility",3 dob: "26-7-2020",4 domain: "infinitbility.com",6};78console.log(Object.values(domain)[0])
Surely, it will log Infinitbility
in the console, because it’s the first value.
let’s check the output.

All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.