Last active
April 15, 2019 12:47
-
-
Save karkranikhil/4d6d02e8c0290c63cd66f0a045649648 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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