Skip to content

Instantly share code, notes, and snippets.

@amorkovin
Created August 12, 2020 08:49
Show Gist options
  • Save amorkovin/5ea0d6eb379473073daf36ae49d00b39 to your computer and use it in GitHub Desktop.
Save amorkovin/5ea0d6eb379473073daf36ae49d00b39 to your computer and use it in GitHub Desktop.
Замыкание JavaScript
function makeCounter() {
let count = 0;
return function () {
return count++;
};
}
let counter = makeCounter()
console.log(counter());
console.log(counter());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment