Created
February 8, 2018 08:10
-
-
Save tfanme/e086b7f0b71f240262f93745f1509e82 to your computer and use it in GitHub Desktop.
一个典型的闭包 + IIFE(Immediately-invoked function expression) F结合的例子
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
/** | |
* 一个典型的闭包 + IIFE(Immediately-invoked function expression) F结合的例子 | |
*/ | |
const generateId = (() => { | |
let i = 0; | |
return (prefix = '') => { | |
i += 1; | |
return `${prefix}${i}`; | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment