Created
January 22, 2016 02:38
-
-
Save jasonblanchard/207a8a315b929f3d0bf8 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
function createRunOnce() { | |
var hasRun = false; | |
return function() { | |
if (hasRun === false) { | |
console.log('I have run'); | |
hasRun = true; | |
} | |
}; | |
} | |
var runOnce = createRunOnce(); | |
runOnce(); | |
runOnce(); | |
runOnce(); | |
runOnce(); | |
runOnce(); | |
// var increment = (function() { | |
// var value = 0; | |
// return function() { | |
// value = value + 1; | |
// return value; | |
// }; | |
// })(); | |
// // var increment = createIncrementor(); | |
// console.log(increment()); | |
// console.log(increment()); | |
// console.log(increment()); | |
// var a = 1; | |
// function someFunc() { | |
// a = 5; | |
// } | |
// someFunc(); | |
// console.log(a); | |
// var i = 'cats'; | |
// for(i = 0; i < 5; i++) { | |
// // console.log(i); | |
// } | |
// for(i = 0; i < 5; i++) { | |
// // console.log(i); | |
// } | |
// console.log(i); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment