Extending javascript literal object
<p>Why JohnDoe.whoAreYou() does return undefined ?:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;script&gt;
    var JohnDoe = {
        //public property
        firstName: "John",
        lastName: "Doe",

        //public method
        whoAreYou: function() {
          alert( "I am literal object and my name is " + this.toString());
        },
        whatIsYourAge: function() {
          alert("My age is " + this.Age);
        }               
    };    
  &lt;/script&gt;

  &lt;script&gt;
    JohnDoe.Age = 10;
    JohnDoe.toString = function() {this.firstName + " " + this.lastName};
    JohnDoe.whoAreYou();    
    JohnDoe.whatIsYourAge();
  &lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
