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();

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Get as e.target the exact element at which onClick is specified?

Get as e.target the exact element at which onClick is specified?

A concise design that completely changed Redux

Datatables Custom Filters — Server Side Ajax

Get start with react js

Kicking off decoupled Drupal & React projects with boilerplate

Angular 12 with reactive Google Map markers based in Google Places autocomplete

Vue | Vuetify -> How to vertically align a <v-select> in a <v-data-table>cell

Ternary Search in JavaScript

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.

More from Medium

Custom events in JavaScript

Promises in JavaScript

Loved and hated JavaScript

8 JavaScript array method you must know