Javascript Modules and Variable Scopes

var executeTask = function() {
console.log("Executing a task");
}
executeTask();
var taskManager = function() {

var executeTask = function() {
console.log("Executing a task");
}

var getTaskStatus = function() {
console.log("Getting task status");
}

return {
executeTask: executeTask,
taskStatus: getTaskStatus
}
}
taskManager().executeTask();
var taskManager = function() {

var executeTask = function() {
console.log("Executing a task");
alert("Executing a task");
}

var getTaskStatus = function() {
console.log("Getting task status");
}

return {
executeTask: executeTask,
taskStatus: getTaskStatus
}
}();
taskManager.executeTask();
(function() {
var taskManager = function() {

var executeTask = function() {
console.log("Executing a task");
alert("Executing a task");
}

var getTaskStatus = function() {
console.log("Getting task status");
}

return {
executeTask: executeTask,
taskStatus: getTaskStatus
}
}();

taskManager.executeTask();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Omar Barguti

Omar Barguti

An enthusiastic architect and full-stack developer with many years working with enterprise software and cloud services in multiple domains.