Although what you posted is seen commonly, I personally don't think it's the best way to do it.
MY_NAMESPACE could evaluate to false for several reasons other than undefined -- the variable could really be defined but be 0 or false or an empty string, and you might end up replacing this value.
MY_NAMESPACE could evaluate to true for several reasons other than already being an object -- it could be a non-zero number or true or a string, and this will cause your script to silently fail, because adding properties to a primitive will fail without an error.
Really, the best way depends on what your goal is. If you don't want to pollute an existing variable/namespace, you should do a typeof check and stop if the variable is already defined but not an object:
if (typeof MY_NAMESPACE == 'undefined') {
// create a new namespace
MY_NAMESPACE = {};
}
if (typeof MY_NAMESPACE == 'object') {
// go ahead
} else {
// MY_NAMESPACE was already defined, but it is not an object
// your script will fail if you continue, so do what you must and stop
}
If your script must work, just blindly create the namespace without any checks (of course, I'm not recommending that you do this).
Edit: (in response to @jball's comment, thought I'd just add it here)
If this namespace is part of a library that you're developing, then it is imperative that you name your namespace carefully to avoid collision. If you do encounter a collision, it's better to just stop loading your library than mix your library with another and get unexpected results.
If this namespace is just for your own application, it should be fairly simple to pick a name that isn't used by any libraries that you're using.