Function Method invocation pattern - Javascript Object

Javascript examples for Object:Object Method

Description

Function Method invocation pattern

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  av a 2 s .com*/
var myObject = {
    value: 0,
    increment: function (inc) {
        this.value += inc;
        return this.value;
    }
};
console.log(myObject.value);
var x = myObject.increment(2);
console.log(x);
    }

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

Related Tutorials