closure
This commit is contained in:
parent
5b195795da
commit
964ed57c42
39 changed files with 365 additions and 461 deletions
|
@ -0,0 +1,13 @@
|
|||
function makeArmy() {
|
||||
|
||||
let shooters = [];
|
||||
|
||||
for(let i = 0; i < 10; i++) {
|
||||
let shooter = function() { // shooter function
|
||||
alert( i ); // should show its number
|
||||
};
|
||||
shooters.push(shooter);
|
||||
}
|
||||
|
||||
return shooters;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue