title: JavaScript "Uncaught TypeError: object is not a function" associativity question
body: <p>The code is as follows:</p>
  <pre><code>&lt;body&gt;
      &lt;a href=&quot;javascript:;&quot; id=&quot;test&quot;&gt;hello&lt;/a&gt;
  &lt;/body&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      document.getElementById(&quot;test&quot;).addEventListener(&quot;click&quot;, 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:</p>
  <blockquote>
  <p>&quot;Uncaught TypeError: object is not a function&quot;</p>
  </blockquote>
  <p>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 semicolon after the &quot;var postTypes&quot; definition then it will be completely fine.</p>
  <p>I was led to believe that JavaScript does not require semicolons, so I'm making a guess that there is some weird associativity rules of function application that I am not fully understanding. Why am I getting this error?</p>