Last active
August 29, 2015 14:18
-
-
Save or9/3af4d2ee109862878241 to your computer and use it in GitHub Desktop.
Revealing module app thing
This file contains 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
var app = (function init(doc, undefined) { | |
// do stuff | |
return Object.defineProperties({}, { | |
"hi": { value: hi }, | |
"bye": { value: bye } | |
}); | |
function hi() { | |
// hi | |
} | |
function bye() { | |
// bye | |
} | |
})(document); |
This file contains 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
undefined = true; | |
var app = (function init(doc, undefined) { | |
var thing = 0; | |
return { | |
hi: hi, | |
bye: bye, | |
something: thing, // copy by value | |
get thing() { | |
return thing; | |
} | |
}; | |
function hi() { | |
thing += 1; | |
} | |
function bye() { | |
thing += 2; | |
} | |
})(document); | |
app.something; // 0 | |
app.thing; // 0 | |
app.hi(); | |
app.something; // 0 | |
app.thing; // 1 | |
app.bye(); | |
app.something; // 0 | |
app.thing; // 3 |
This file contains 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
var app = (function init(doc, undefined) { | |
// do stuff | |
return { | |
hi: hi, | |
bye: bye | |
}; | |
function hi() { | |
// hi | |
} | |
function bye() { | |
// bye | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment