While reviewing some old JavaScript code in his company's core application, Dan Howard came across this pain.

For some reason, the "developer" decided that he has to Javascript's Eval() for each line of code. Some in a try/catch... others without...

 

function selectCompany(companyName,nNo,cMask) {
   companyName = unescape(companyName);
   if (window.opener){
      jStr1 = "window.opener.document.all.IcompanyName.value = trimString(unescape(companyName))"
      jStr2 = "window.opener.document.all.IcompanyNo.value = nNo"
      jStr3 = "window.opener.document.all.PolicyNumber.mask = cMask"
      jStr5 = "window.opener.document.all.PolicyNumber.title = cMask"
      jStr4 = "window.opener.document.all.IcompanyName.reset()"
      eval(jStr1)
      eval(jStr2)
      try {eval(jStr3)}catch(e){}
      try {eval(jStr4)}catch(e){}
      try {eval(jStr5)}catch(e){}
      if(window.opener.RefreshListByInsurer){
         window.opener.execScript(window.opener.RefreshListByInsurer(nNo,cMask));
      }
   }
   window.close()
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!