Skip to content

Instantly share code, notes, and snippets.

@goxr3plus
Last active March 7, 2019 09:50
Show Gist options
  • Save goxr3plus/7acd34ac3bf70dcf3ff13835a181af30 to your computer and use it in GitHub Desktop.
Save goxr3plus/7acd34ac3bf70dcf3ff13835a181af30 to your computer and use it in GitHub Desktop.
Javascript Closures example
//-----------------------Closures ------------------------------//
function retirement(retirementAge) {
let a = " years until retirement";
return function(yearsOfBirth) {
let age = 2019 - yearsOfBirth;
console.log(retirementAge - age + a);
};
}
// let retirementUs = retirement(66);
retirement(66)(1995);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment