Javascript Data Type How to - Put identifiers to objects inside an array








Question

We would like to know how to put identifiers to objects inside an array.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from www .  j a va  2s.  c o m-->
    var arr = {0:1, 1:"one", b:{name:"A", surname : "Jack"}};
    document.writeln(arr.b.name);

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

The code above is rendered as follows: