Access element name with no value from array - Javascript Array

Javascript examples for Array:length Property

Description

Access element name with no value from array

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*w  ww. ja  va2s  .  c  o m*/

var arr = [];
var person={fname:"John",lname:"Doe",age:25};
arr.push(person);
for (var i=0; i < arr.length; i++)
{
   document.write(arr[i].lname+ " ");
}


    });

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

Related Tutorials