Created
December 27, 2020 21:30
-
-
Save reime005/d445effbb89bb68d7267ae231c55f178 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
const chain = () => { | |
let str = 't'; // 'var' also possible | |
return input => { | |
str += input; | |
return str; | |
}; | |
}; | |
const t = chain(); | |
console.log(t('e')); // prints 'te' | |
console.log(t('st')); // prints 'test' | |
console.log(str); // ReferenceError: str is not defined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment