I'm just wondering what the "best" way to do namespacing in javascript is. I know this has been asked a million times, but I've seen many methods including simply declaring an object as your namespace containings its relevant variables and methods. Is this the preferred way or is it better to use the the protype construct as in:
function Namespace() {
}
Namespace.prototype.newMethod = function() {
};
//...
// now to use this:
var namespace = new Namespace();
namespace.newMethod();
I'd also like to know why one method is preferred over another.
Namespace.prototype?