Use function source code to create a member function and display its content - Javascript Object

Javascript examples for Object:Object Method

Description

Use function source code to create a member function and display its content

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 w  w  w.j a  v a2  s.  co m
var items = [];
items.push({
    example: function() {
        if(0 > 1) {
            return 'true';
        } else {
            return 'false';
        }
    }()
});
document.write(items[0].example);
    });

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

Related Tutorials