Last active
December 22, 2015 13:08
-
-
Save j0ni/6477035 to your computer and use it in GitHub Desktop.
testing out the power of hoisting - turns out (obviously in retrospect) the continuation function isn't evaluated at code load time, so you have to run the printList function before the printItem function is available externally.
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
/*global exports, module*/ | |
exports = module.exports = (function () { | |
var api = {}; | |
api.printList = function () { | |
['hello', 'mr', 'smarty', 'pants'].forEach(api.printItem = function (i) { | |
console.log(i); | |
}); | |
}; | |
return api; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment