I would like some help with getting the size of an array inside an object:
var st = { "itema":{...},"itemb":[{"id":"s01","cd":"c01","dd":"d01",....}{"id":"s02","cd":"c02","dd":"d02",....}]}
How would you get a count of the objects inside "itemb"
(in this case 2)?
This question is related to
javascript
arrays
object
count
Arrays have a property .length
that returns the number of elements.
var st =
{
"itema":{},
"itemb":
[
{"id":"s01","cd":"c01","dd":"d01"},
{"id":"s02","cd":"c02","dd":"d02"}
]
};
st.itemb.length // 2
Source: Stackoverflow.com