To get the size of an array in an object with JavaScript, we use the length
property.
For instance, we write
const st = {
itemA: {},
itemB: [
{ id: "s01", cd: "c01", dd: "d01" },
{ id: "s02", cd: "c02", dd: "d02" },
],
};
console.log(st.itemB.length);
to get the length of the st.itemB
array property with st.itemB.length
.