Javascript "Uncaught TypeError: object is not a function" associativity question
<p>Code is as follows:</p>

<pre><code>&lt;body&gt;
    &lt;a href="javascript:;" id="test"&gt;hello&lt;/a&gt;
&lt;/body&gt;

&lt;script type="text/javascript"&gt;
    document.getElementById("test").addEventListener("click", function () {
      test()
    }, false)
    function test() {
      var postTypes = new Array('hello', 'there')   
      (function() { alert('hello there') })()
    }
&lt;/script&gt;
</code></pre>

<p>This will throw an "Uncaught TypeError: object is not a function".  If I wrap the anonymous function call/invocation in another set of parentheses it will execute the alert, but still give me an error.  If I put a semi-colon after the "var postTypes" definition then it will completely fine.</p>

<p>I was led to believe that javascript does not require semi-colons, so I'm making a guess that there is some weird associativity rules of function application that I am not fully understanding.  I hope someone can give me the answer to why I am getting this error.</p>

<p>Thanks.</p>
