Skip to content

Instantly share code, notes, and snippets.

@keriati
Created June 22, 2012 20:27
Show Gist options
  • Save keriati/2974984 to your computer and use it in GitHub Desktop.
Save keriati/2974984 to your computer and use it in GitHub Desktop.
Revealing module pattern
(function() {
var NS = {};
NS.Parent = function() {
var privateFoo = "Private foobar in Parent";
function _foo(data) {
console.log("foo: " + data);
console.log(privateFoo);
}
function foo(data) {
_foo(data);
}
return {
foo: foo
}
}();
NS.Child = function() {
function bar(data) {
console.log("bar: " + data);
}
return {
bar: bar,
foo: NS.Parent.foo
};
}();
window.NS = NS;
})();
NS.Child.bar("foo");
NS.Child.foo("bar");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment