Javascript - How do you call a function inside a class from within that class?
<p>I am trying to call the function MyMethod from within a object but none of the syntax below works.
There must be a really obvious error below but I can't see it.</p>

<pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;

   &lt;script type="text/jscript"&gt;

     function MyObject() {

       //how do I get one of these to work??
       this.MyMethod; //does not work
       this.MyMethod(); //does not work either
       MyMethod(); //does not work either

       this.MyMethod = function () {
         alert('It works');
       }
     }

     var test = new MyObject();

   &lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;

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