How do I declare a namespace in JavaScript?

preview_player
Показать описание
#short
#javascript
#namespaces
#javascript-namespaces
How do I create a namespace in JavaScript so that my objects and functions aren't overwritten by other same-named objects and functions? I've used the following:
if (Foo == null || typeof(Foo) != "object") { var Foo = new Object();}

Is there a more elegant or succinct way of doing this?
Рекомендации по теме
welcome to shbcf.ru