title: Javascript - How do I invoke an anonymous method as a variable and access its properties and methods?
body: <p>I've read that we can invoke an anonymous function as a variable. However I'm trying to do that and in addition to it I want to access its properties and methods. Here is my code</p>
  
  <pre><code>var cooking = function(){
          this.dessert = "Ice Cream";
          this.numberOfPortions = 20;
          this.doubleLunch = function(){this.numberOfPortions = 40;
              document.write(this.numberOfPortions);};
          };
  
  document.write(cooking.dessert);
  </code></pre>
  
  <p>But I don't get anything. Can you say me what am I doing wrong? Thanks</p>