Accessing values of JSON object via hasOwnProperty - Javascript JSon

Javascript examples for JSon:JSon Object

Description

Accessing values of JSON object via hasOwnProperty

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(){/*from w  ww .  j ava 2s  .c  om*/
var data = [{
    x: "something1",
    y: "something2",
    z: "10",
    w: "20"
}];
for (var i = 0; i < data.length; i++) {
    for (var propertyName in data[i]) {
        if (data[i].hasOwnProperty(propertyName)) {
            console.log(data[i][propertyName]);
        }
    }
}
    }

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

Related Tutorials