Created
November 23, 2017 16:50
-
-
Save valsaven/69452f8c1bce464aefb8ba1ef5a74b08 to your computer and use it in GitHub Desktop.
Javascript Closures
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
const logger = (function(message) { | |
const log = []; | |
const show = 123; | |
const logging = (message) => { | |
const error = { | |
date: new Date(), | |
message | |
}; | |
return log.push(error); | |
}; | |
logging.show = () => log; | |
return logging; | |
}()); | |
console.log(logger('Catastrophic error!')); | |
console.log(logger('Nope, nope, nope!')); | |
console.log(logger.show()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment