Define a property based on another property - Javascript Object

Javascript examples for Object:Object Property

Description

Define a property based on another property

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() {/*  ww w.ja va2s .c o m*/
var someNameSpace = (function(){
   var x1 = 100;
    return {
        x1: x1,
        x2: x1 * 0.5
    };
})();
console.log(someNameSpace)
    });

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

Related Tutorials