Javascript Data Type How to - Identify a property within an array of objects as an array








Question

We would like to know how to identify a property within an array of objects as an array.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from   ww w.ja  v  a  2s . com-->
var pagesArray = [{
   category: 'pages1',
   pages: [
       'firstPage1',
       'secondPage1',
       'thirdPage1',
       'fourthPage1'
   ]
}];
document.writeln(pagesArray[0].pages instanceof Array);

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: