When both files are included in the page, anything declared with var outside of any object is included in the global namespace and can be accessed anywhere. You should be able to easily get to fooMYNS from anywhere on your page.
Check out this other question/answer: How do I declare a namespace in JavaScript?
However, a very nice way I've seen to explicitly declare what should be shared comes from node.js and well implemented in Coffeescript As described here: How do I define global variables in CoffeeScript?
root = exports ? this
root.foo = -> 'Hello World'
Coffeescript automatically wraps all individual files in a closure, which really helps you not pollute the global javascript namespace. As a result, it forces you to use the idiom above to ONLY expose the exact API you want.
The code above checks first for export (the node.js global), otherwise uses the closure scope (this) and explicitly attaches a method (foo) to that global space.
Now in any other file, foo
will be globally accessible, but anything else not explicitly made global will not be.