Created
January 13, 2015 20:41
-
-
Save amarinelli/8d5e360af516a48604ae to your computer and use it in GitHub Desktop.
Sample JS template for writing an IIFE
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
// 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