Created
December 31, 2017 17:48
-
-
Save ldco2016/a7971429deb36729ecd621ac5b7d1cbd to your computer and use it in GitHub Desktop.
Budgety app
This file contains hidden or 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
// immediately invoked function expression | |
// its an anonymous function wrapped in parentheses | |
// Step 1: JS Runtime executes this line and this anonymous | |
// function is declared and immediately called because | |
// of (); operator below. | |
var budgetController = (function() { | |
// Step 2: Then this is declared and it returns an | |
// object below it. | |
// this part of the code is private | |
var x = 23; | |
// this is a private function | |
var add = function(a) { | |
return x + a; | |
} | |
// this part of the code is public | |
// return an object containing a method | |
return { | |
publicTest: function(b) { | |
// calling the add function with b | |
console.log(add(b)); | |
} | |
} | |
// invoking the function | |
})(); | |
var UIController = (function() { | |
// Some code | |
// invoking the function | |
})(); | |
// A way to read data from the user interface and add that data to the budgetController | |
var controller = (function(budgetCtrl, UICtrl) { | |
var z = budgetCtrl.publicTest(5); | |
})(budgetController, UIController); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment