Hi Friends 👋,
Welcome To Infinitbility! ❤️
To get length of json array in javascript, use .length
property it will return number of element avaialable in json array.
Let’s see how to use .length
property in json array variable.
let arr = ["Infinitbility", "aGuideHub", "SortoutCode"];
console.log(arr.length);
// Output
// 3
Today, I’m going to show you How do I get json array length in javascript, as above mentioned, I’m going to use the above-mentioned Array.length
property.
Let’s start today’s tutorial how do you get json array length in javascript?
Javascript get json array length example
Here, we will take sample json array variable with some data and use Array.length
property to get count of json array elements.
let arr = ["Infinitbility", "aGuideHub", "SortoutCode"];
console.log(arr.length);
// Output
// 3
Javascript get json array of object length example
Here, we will take sample json array of object variable with some data and use Array.length
property to get count of json array elements.
let arr = [
{
name: "Infinitbility"
},
{
name:"aGuideHub"
},
{
name:"SortoutCode"
}
];
console.log(arr.length);
// Output
// 3
I hope it helps you, All the best 👍.