(Function () {var namespacearray = []; function namespaceobject (name, fullname) {This. fullname = fullname; this. name = Name ;}; var namespacemanager ={ namespaces: namespacearray, Global: This}; function using (namespace, Action) {If (! Namespace) throw new error ('namespace cannot be blank. '); Else if (typeof (namespace )! = "String") throw new error ('namespace can only be a string. '); Else if (namespace. charat (0) = '. '| namespace. charat (namespace. length-1) = '. '| namespace. indexof (".. ")! =-1) {Throw new error ("invalid namespace:" + namespace + ". ");} Var parentns = namespacearray [namespace]; If (! Parentns) {var NSS = namespace. split ('. '); //-split namespace var parentns = namespacemanager. global; //-assume that the upper level is the global namespace var fullname; For (VAR I = 0; I <NSS. length; I ++) {var NS = NSS [I]; If (! Fullname) fullname = ns; else fullname = fullname + "." + NS; var nsobject = parentns [ns]; If (! Nsobject) {nsobject = new namespaceobject (name, fullname); parentns [ns] = nsobject;} else if (typeof nsobject! = "Object") throw new error (NSS. Slice (0, I). Join ('.') + "non-object namespace. "); Else nsobject = parentns [ns]; parentns = nsobject;} namespacearray [namespace] = parentns;} If (typeof action =" function ") {action. call (parentns);} If (parentns! = Namespacemanager. Global) {for (var I in parentns) {If (! Namespacemanager. global [I]) namespacemanager. global [I] = parentns [I] ;}} return parentns ;}; function clearusing (namespace) {var parentns = namespacearray [namespace]; If (parentns) {for (var I in parentns) {if (I = "name" | I = "fullname" | typeof parentns [I] = "namespaceobject") continue; if (namespacemanager. global [I]) {Delete namespacemanager. global [I] ;}}} window. using = using; wi Ndow. clearusing = clearusing; window. namespacemanager = namespacemanager; using ("sofire. test ", function () {This. helloclass = function () {This. name = "hello" ;};}); alert (helloclass); clearusing ("sofire. test "); If (typeof helloclass! = "Undefined") {alert ("exits");} else alert ("not exits"); Using ("sofire. test ", function () {This. helloclass2 = function () {This. name2 = "hello2" ;}}); alert (helloclass); alert (helloclass2 );})();