I haven't seen much documentation on this so I thought I would talk a little about what I have learned about javascript scope. So say you want to put all your methods into a main class and have sub classes and methods several layers deep. Everything would be so clean and organized but how the heck do you do that in javascript? Unfortunatly javascript does this very different from say ruby or java.
In javascript if you wanted to do something like google.map.Refresh()
first you need to make your main object like this.
google = {}
then make your sub object with a constructor like this.
google.map = function() {
}
then you can add your class methods to your map object like this.
google.map.prototype.Refresh = function() {
//map refresh code
}
if you decided to make google.foo.map.Refresh() all you do is add this in below your main object.
google.foo = {}
google.foo.map = function() {
}
google.foo.map.prototype.Refresh() = function() {
}
It is important to note that you can only add methods to objects with constructors so google.foo can't have a method but google.foo.maps can have the Map method since it was made with a constructor. I hope this helps clarify things while you organize your javascript.