Check if object member exists in nested object - Javascript Object

Javascript examples for Object:Private Member

Description

Check if object member exists in nested object

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
var my = {// w w w  .java2s.c o m
    member:{
        member:{
            member:{value:1}
        }
    }
};
var result = ((((my || {}).member || {}).member || {}).member || {}).value;
console.log( result );

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

Related Tutorials