When I create a JS namespace (myNamespace) with a public method (myPublicMethod)
jsfile1.js
var myNamespace=(function() {
var myPublicMethod=function(){
alert("hello world");
}
return
{
myPublicMethod:myPublicMethod
};
})();
and then have a separate .js file which encapsulates its methods
jsfile2.js
(function(){
myNamespace.myPublicMethod();
})();
The two files are then included in an html file
<script src="jsfile1.js"...>
<script src="jsfile2.js" ...>
When I try to call myPublicMethod() I get an error that myNamespace does not exist. Is this because it is encapsulated in the jsfile2.js file?
Thanks