Below is a code snippet for a Immediately invoked function expression IIFE. An IIFE is used to keep code out of the global namespace.
(function() { var createWorker = function() { var workerCount = 0; var task = function() { workerCount += 1; console.log("task " + workerCount); }; return { task: task }; }; var prg = createWorker(); prg.task(); }());