Creating an object with a constructor and named members - Javascript Object

Javascript examples for Object:Constructor

Description

Creating an object with a constructor and named members

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>so</title> 
   </head> 
   <body> 
      <script>
        function fn(arg){//w  ww  .j  ava 2s . c  o  m
            var init = arg;
            return {
                meth:function(arg){
                    console.log(init + arg);
                }
            };
        };
        var obj = fn('hi');
        obj.meth('asdf');
    
      </script>  
   </body>
</html>

Related Tutorials