for ( var I = 0; I <xx.length; I ++ ) { ((I) => { XX [I] .onclick = () => { // code executed }; }) (I); }