Calling a function without parentheses - Javascript Function

Javascript examples for Function:Function Argument

Description

Calling a function without parentheses

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  a 2s .c o m*/
var o = {};
Object.defineProperty(o, "helloWorld", {
    get: function() {
        console.log("hello world");
    },
    set: undefined
});
o.helloWorld; // will show "hello world" in console
    });

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

Related Tutorials