title: addEventListener (and removeEventListener) function that need param
body: <p>I need to add some listeners to 8 object (palms).
  These object are identical but the behaviour have to change basing to their position.
  I have the follow (ugly) code:</p>
  
  <pre><code>root.palmsStatus = ["B","B","B","B","B","B","B","B"];
  
  if (root.palmsStatus[0] !== "N")
    root.game.palms.palm1.addEventListener("click", palmHandler = function(){ palmShakeHandler(1); });
  if (root.palmsStatus[1] !== "N")
    root.game.palms.palm2.addEventListener("click", palmHandler = function(){ palmShakeHandler(2); });
  if (root.palmsStatus[2] !== "N")
    root.game.palms.palm3.addEventListener("click", function(){ palmShakeHandler(3); });
  if (root.palmsStatus[3] !== "N")
    root.game.palms.palm4.addEventListener("click", function(){ palmShakeHandler(4); });
  if (root.palmsStatus[4] !== "N")
    root.game.palms.palm5.addEventListener("click", function(){ palmShakeHandler(5); });
  if (root.palmsStatus[5] !== "N")
    root.game.palms.palm6.addEventListener("click", function(){ palmShakeHandler(6); });
  if (root.palmsStatus[6] !== "N")
    root.game.palms.palm7.addEventListener("click", function(){ palmShakeHandler(7); });
  if (root.palmsStatus[7] !== "N")
    root.game.palms.palm8.addEventListener("click", function(){ palmShakeHandler(8); });
  </code></pre>
  
  <p>I have two needs:</p>
  
  <p>1) doesn't use an anonymous function on click event.</p>
  
  <p>I wrote this code, but it doesn't work</p>
  
  <pre><code>root.game.palms.palm8.addEventListener("click", palmShakeHandler(8));
  </code></pre>
  
  <p>So this one works fine</p>
  
  <pre><code>root.game.palms.palm8.addEventListener("click", function(){ palmShakeHandler(8); });
  </code></pre>
  
  <p>But I didn't understand how remove the event listener.
  I try this solution, but it doesn't work</p>
  
  <pre><code>root.game.palms.palm8.addEventListener("click", palmHandler = function(){ palmShakeHandler(8); });
  root.game.palms.palm8.removeEventListener("click", palmHandler);
  </code></pre>
  
  <p>2) add and remove listener in a for cycle</p>
  
  <p>I wrote the follow code but the behaviour is not correct.</p>
  
  <pre><code>  for (i=1; i &lt;= root.palmsStatus.length; i++){
      if (root.palmsStatus[i-1] !== "N"){
        root.game.palms["palm" + i].addEventListener("click", function(){ palmShakeHandler(i); });
      }
    } 
  </code></pre>
  
  <p>the listeners was added but the value of the parameter passed to the <strong>palmShakeHandler</strong> is always 8.</p>
  
  <p>Nobody could help me to fix these issues?</p>