Skip to content

Instantly share code, notes, and snippets.

@karkranikhil
Last active April 15, 2019 12:47
Show Gist options
  • Select an option

  • Save karkranikhil/4d6d02e8c0290c63cd66f0a045649648 to your computer and use it in GitHub Desktop.

Select an option

Save karkranikhil/4d6d02e8c0290c63cd66f0a045649648 to your computer and use it in GitHub Desktop.
function createArrFunction(){
const arr=[]
for(var i=0;i<5;i++){
arr.push(
(function(){
return function(){
console.log(i)
}
})(i))}
return arr
}
const getArrFunction = createArrFunction()
getArrFunction[0]() // return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment