If you have a global function named foo(), and a 3rd party library or someone else in your organization comes along and defines foo() as well, There Can Be Only One and the first defined will lose.

As Wade mentioned, it's also a tidiness thing. Everything in one place can make for a giant morass of code to sort through. Take a traipse through the Window object (where everything in global scope is put) some time to see all the stuff already in there.

While execution speed might become significant with hundreds of thousands of global definitions, I suspect it's not worth worrying about otherwise. Names are hashed into scopes so the lookup is O(1), and nested namespaces will probably result in more memory usage overall depending on what the default Javascript hashmap internal size is and how the hashmaps are grown. A short test with the Chrome profiler shows that this is indeed the case: an Object with 100,000 items in it takes up 20% less memory that 100 Objects with 1000 items each. In either case the memory overhead is negligible at reasonable numbers of items, as you would see in any but the most horrifically large JavaScript applications.