title: Is "clear" a reserved word in Javascript?
body: <p>I just spent a long time figuring out that I shouldn't use clear() as the name of a function in Javascript:</p>
  
  <pre><code>&lt;head&gt;
      &lt;script type="text/javascript" src="Array.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      Hello!!!!&lt;br&gt;
      &lt;button type="button" onClick="clear()" id="ppp"&gt;Shoo!&lt;/button&gt;&lt;br&gt;
      &lt;button type="button" onClick="add()" id="add"&gt;Add a few elements&lt;/button&gt;&lt;br&gt;
      &lt;button type="button" onClick="check()" id="check"&gt;Check the array&lt;/button&gt;&lt;br&gt;
      &lt;p id="results"&gt;Results will appear here.&lt;/p&gt;
      &lt;script type="text/javascript"&gt;
  initialize();
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Here's Array.js:</p>
  
  <pre><code>var results;
  
  function initialize(){
   results = document.getElementById("results");
  }
  
  function add() {
  results.firstChild.data="add";    
  }
  
  function clear() {
  results.firstChild.data = "Hello?";
  }
  
  function check() {
  results.firstChild.data = "check";
  }
  </code></pre>
  
  <p>Symptoms: Clicking the 'add' and 'check' buttons gives me the result I expect, but clicking the 'clear' button does nothing.</p>
  
  <p>If I rename <strong>clear()</strong> to <strong>clearxyz()</strong>, it works fine. </p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Is "clear" a reserved word? I don't see it on the list:
  <a href="https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words" rel="noreferrer">https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words</a></li>
  <li>Is there a debugging trick I should be using to figure this kind of
  thing out in the future? It took me a long time (I'm a noob!) to
  figure out that the name of the function was my problem.</li>
  </ol>
  
  <p>Many thanks.
  Edit: I'm using Firefox 6.0, and I added a line break to show where Array.js starts.</p>