Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

Today, You will learn to get all object values JSON object in javascript, here we will use the for.. in loop to iterate an object to get their values.

Sometimes, we don’t know the keys but we to show all object values in our project, we want some dynamic way to do it, so today we are going to do the same.

Here, we will use the for.. in loop which can iterate objects, in the loop we will get keys to object, which we can use to access object values.

let’s understand, for example, here we will create a sample object and we will use in for.. in loop and check object values in the console.

const domain = {
  name: "Infinitbility",
  dob: "26-7-2020",
  domain: "infinitbility.com",
  email: "[email protected]",
};

for(let key in domain){
  console.log(key, domain[key])
  console.log("----------")
}

When you run the above code, you will get all keys and values in the console.

let’s check the output.

JavaScript, get array from json object example
JavaScript, get array from json object example

All the best đź‘Ť.