Skip to content

Instantly share code, notes, and snippets.

@imbcmdth
Created June 20, 2012 08:16
Show Gist options
  • Save imbcmdth/2958767 to your computer and use it in GitHub Desktop.
Save imbcmdth/2958767 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>IIFE App</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<input type="button" id="idButton" value="Click Me!">
<div id="idOutput"></div>
<script type="text/javascript" src="LoadIIFE.js"></script>
</body>
</html>
var appSpace = (function () {
'use strict';
var x = 10,
button = document.getElementById('idButton'),
output = document.getElementById('idOutput');
button.addEventListener("click", function () {
output.innerHTML = x++;
});
return {
z : 0,
appSum: function (y) {
return x + y;
},
appMult: function (y) {
return x * y;
},
setX: function (y) {
x = y;
},
getOutput: function () {
return output;
}
};
})();
appSpace.getOutput().innerHTML = appSpace.appMult(5) + '<br />';
appSpace.getOutput().innerHTML += appSpace.appSum(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment