Created
June 22, 2012 20:27
-
-
Save keriati/2974984 to your computer and use it in GitHub Desktop.
Revealing module pattern
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
(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