Skip to content

Instantly share code, notes, and snippets.

@j0ni
Last active December 22, 2015 13:08
Show Gist options
  • Save j0ni/6477035 to your computer and use it in GitHub Desktop.
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.
/*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