Created
February 14, 2018 09:16
-
-
Save alexmasyukov/159c38cf468320f8813e1340ea694e59 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
function createCounter(counter = 0) { | |
return function() { | |
return console.log(counter++); | |
} | |
} | |
var tic = createCounter(9); | |
// console.log(counter); // будет не доступна из вне | |
tic(); | |
tic(); | |
tic(); | |
создается область видимости для функции на которую ссылается tic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment