Last active
April 15, 2019 12:36
-
-
Save karkranikhil/7a745fcae5449e5265652a036e42d851 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(let i=0;i<5;i++){ | |
| arr.push(function(){ console.log(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