Skip to content

Instantly share code, notes, and snippets.

@amarinelli
Created January 13, 2015 20:41
Show Gist options
  • Save amarinelli/8d5e360af516a48604ae to your computer and use it in GitHub Desktop.
Save amarinelli/8d5e360af516a48604ae to your computer and use it in GitHub Desktop.
Sample JS template for writing an IIFE
// Code goes here
(function() {
var createWorker = function() {
var workCount = 0;
var task1 = function() {
workCount += 1;
console.log("task1 " + workCount);
};
var task2 = function() {
workCount += 1;
console.log("task2 " + workCount);
};
return {
job1: task1,
job2: task2
};
};
var worker = createWorker();
worker.job1();
worker.job2();
worker.job2();
worker.job1();
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment