I appreciate there are a few questions here already about how to identify an array. However, I can't find anything regarding identifying an array within an array of objects.
Given the following array:
var pagesArray = [{
category: 'pages1',
pages: [
'firstPage1',
'secondPage1',
'thirdPage1',
'fourthPage1']
}
}];
I have tried to loop through and identify that pages
is also an array like so:
EDIT
Actually o
in the next example should have been pagesArray
but I've left it as is so that the answers make sense.
for(var p in o){
console.log(typeof p);
console.log(p instanceof Array)
console.log(Object.prototype.toString.call(p))
}
The output returned for pages
is:
string
false
[object String]
Is there a way to correctly identify that the property is an array or am I misunderstanding something?