Created
May 18, 2017 06:15
-
-
Save bluepnume/32223ad749852c1f99e9998f25b52d6f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Create a 'once' function that generates a new function which can only be called once | |
function sayHello() { | |
console.log('hello'); | |
} | |
var sayHelloOnce = once(sayHello); | |
sayHelloOnce(); // logs 'hello' | |
sayHelloOnce(); // does nothing | |
sayHelloOnce(); // does nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Create a 'once' function that generates a new function which can only be called once