Re:JavaScript Interview Question
by dmvaldman on Thursday January 20, 2011 @01:08PM
(#2124580)
ahh thank you this makes more sense. If I understand you correctly...
- each list item has a pointer to a function: alert(i) (functions are first class objects)
- the value of i is determined from the outer function (which is in some unraveled way the for(i=0; i<els.length; i++)) because it is within the scope of the above function
-link item executes alert(i) with i = 4, when clicked.
- each list item has a pointer to a function: alert(i) (functions are first class objects)
- the value of i is determined from the outer function (which is in some unraveled way the for(i=0; i<els.length; i++)) because it is within the scope of the above function
-link item executes alert(i) with i = 4, when clicked.