Skip to content

Instantly share code, notes, and snippets.

@alexmasyukov
Created February 14, 2018 09:16
Show Gist options
  • Save alexmasyukov/159c38cf468320f8813e1340ea694e59 to your computer and use it in GitHub Desktop.
Save alexmasyukov/159c38cf468320f8813e1340ea694e59 to your computer and use it in GitHub Desktop.
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