Return an object from a function - Javascript Function

Javascript examples for Function:Function Return

Description

Return an object from a function

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. j  a v a2 s  .c o  m
var optionScope= new function() {
    return {
        data: function () {
            return {stage:'defaultValue'}
        }
    }
}
optionScope.data().stage = 'b';
console.log(optionScope.data().stage)
    }

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

Related Tutorials