function reference instead of function body - in a loop (with argument)
<p>I would like to replace this:</p>

<pre><code>for( var i=0; i&lt;elementArray.length; i++ )
   elementArray[i].click(function(){
      console.log("element clicked - selectedElementIndex = " + i);                    
   });
</code></pre>

<p>with something like:</p>

<pre><code>for( var i=0; i&lt;elementArray.length; i++ )
    elementArray[i].click( onElementClick(i) );

function onElementClick( i ){
   console.log("element clicked - selectedElementIndex = " + i ); 
}
</code></pre>

<p>how can I do it ? :)</p>
