Basically, I have the following array (or JSON):
apps = {
app1:
[
"ci-extension",
"Unnamed",
"<h1>Hello world!</h1>"
],
app2:
[
"ci-extension",
"Another one!",
"Cool!"
],
}
Is there any way to determine how many children does the array have?
E.g. in this case the answer is 2
: app1 & app2. And if we add one more object "application" the answer will be 3
. I tried the following:
apps.length
//returns "undefined"
for (i = 0; apps[i] != undefined; i++) {
console.log(apps[i]);
//also returns "undefined"
//I am later gonna use also the values in the child, so I stored all the children to a new array
meta.push(apps[i]); //"meta" here is another vriable with an array in it
}
(if this makes any sense)
I expected the for
to return something like this:
app1
app2
application (if you count the new object we added)And the value of
meta
to be["app1", "app2", "application"]
.
My mind got totally obfuscated. I've got no idea where and what I am doing wrong, so any help would be highly appreciated. Thanks in advance!
EDIT:
If there is some way to push()
elements into apps
I will kindly ask you to light me up. Thanks again!