javascriptで名前空間を使う
わかりやすい、使いやすいのでメモ
http://qiita.com/mocha/items/c6a626416daaa04d0668
↑このページのものをそのままです
var top = top || {}; // ancestor namespace top.second = top.second || {}; // ancestor namespace (function (third) { // namespace // private property var privPropName = "privPropValue"; // private method function privFuncName() { } // public function third.funcName = function () { } // public class third.ClassName = (function () { function ClassName() { } return ClassName; })(); // public singleton object third.objectName = (function () { return { }; })(); })(top.second.third = top.second.third || {}); // usage top.second.third.funcName(); var instance = new top.second.third.ClassName(); top.second.third.objectName;