[問題] javascript執行問題

看板Web_Design作者 ( )時間15年前 (2010/05/13 23:08), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
<script> var calculate_sqrt_patt= /\(Math.sqrt\(\d+\)\)/g; var metPatt; calculate_sqrt_patt.compile(calculate_sqrt_patt); var CurrentResult="(Math.sqrt(121))+(Math.sqrt(25))+(Math.sqrt(81))+(Math.sqrt(144))+(Math.sqrt(169))+(Math.sqrt(49))"; while((metPatt=calculate_sqrt_patt.exec(CurrentResult))!=null) { var replaceString; var str=metPatt.toString(); alert(CurrentResult+":\n"+str); replaceString=eval(str).toString(); CurrentResult=CurrentResult.replace(str,replaceString); } /* (Math.sqrt(121))+(Math.sqrt(25))+(Math.sqrt(81))+(Math.sqrt(144))+(Math.sqrt(169))+(Math.sqrt(49)): (Math.sqrt(121)) 11+(Math.sqrt(25))+(Math.sqrt(81))+(Math.sqrt(144))+(Math.sqrt(169))+(Math.sqrt(49)): (Math.sqrt(81)) 11+(Math.sqrt(25))+9+(Math.sqrt(144))+(Math.sqrt(169))+(Math.sqrt(49)): (Math.sqrt(169)) */ </script> 想請問為啥結果是跳著換的? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.160.179.238
文章代碼(AID): #1Bx1NwPo (Web_Design)
文章代碼(AID): #1Bx1NwPo (Web_Design)