这是我在《高级3》看到的一段代码,不明白这种写法怎么被优化了?functioncreateXHR(){if(typeofXMLHttpRequest!='undefined'){createXHR=function(){returnnewXMLHttpRequest();};}elseif(typeofActiveXObject!='undefined'){createXHR=function(){if(typeofarguments.callee.activeXString!='string'){varversion=["MSXML2.XMLHttp.6.0","MSXML2.XMLHttp.3.0"],i,len;for(i=0,len=version.length;itry{ newActiveXobject[version[i]];arguments.callee.activeXString=versions[i];break;}catch(ex){//skip}}}}}else{createXHR=function(){thrownewError("NoXHRobjectavailable.");}}returncreateXHR();}createXHR();
慕神8447489
相关分类