Object context change and eval - Javascript Object

Javascript examples for Object:Object Context

Description

Object context change and eval

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   ww w  . j  ava2  s.c  o  m
var myObject = {
      property1: 20,
      property2: 5000
};
console.log(myObject.property1);
with(myObject){
 console.log( property1 );
 console.log( eval('property1+property2') );
}
    }

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

Related Tutorials