Last active
August 29, 2015 14:15
-
-
Save Usse/93bbe325f79f1369b48b to your computer and use it in GitHub Desktop.
Revealing module pattern
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
(function() { | |
var createWorker = function() { | |
var workCount = 0; | |
var task1 = function() { | |
workCount += 1; | |
console.log('Doing task2 :' + workCount); | |
} | |
var task2 = function() { | |
workCount += 1; | |
console.log('Doing task1 :' + workCount); | |
} | |
return { | |
job1: task1, | |
job2: task2 | |
}; | |
}; | |
var worker = createWorker(); | |
worker.job1(); | |
worker.job2(); | |
worker.job1(); | |
worker.job2(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment