Created
August 31, 2017 05:01
-
-
Save ifucolo/6980bde6b648c74acdb2dd96ea350cd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var counter, quantity = 10; | |
var list = []; | |
for(counter = 0; counter < quantity; counter++){ | |
var object = {}; | |
object.onClick = (function(counter) { | |
return function() { | |
alert(counter); | |
} | |
})(counter) | |
list.push(object); | |
} | |
list[1].onClick() | |
list[5].onClick() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment