Javascript : Pass String by value
<p>I have a little problem with one of my javascript code. Here is the code</p>

<pre><code>//assume array is an array containing strings and myDiv, some div in my doc
for(var i in array) {
    var myString = array[i];
    var a = document.createElement('a');
    a.innerHTML = myString;
    a.addEventListener("click", function() {myFunc(myString)}, false);
    myDiv.appendChild(a)
}
function myFunc(s) {alert(s);}
</code></pre>

<p>However, since Strings are passed by reference in JavaScript, I see always the last string of my <code>array</code> when I click on the link <code>a</code> in question. Thus, my question is "How can I pass <code>myString</code> by value ?". Thank you for your help !
Phil</p>
