do...while 循环是 while 循环的变种。该循环程序在初次运行时会首先执行一遍其中的代码,然后当指定的条件为 true 时,它会继续这个循环。所以可以这么说,do...while 循环至少执行一遍其中的代码,即使条件为 false,因为其中的代码执行后才会进行条件验证。现在来分析:(1):先执行到最后一个e 的时候:do{result=patt1.exec("The best things in life are free");document.write(result);}这时页面上的result就是eeeeee (2):下来继续验证执行result的值为eeeeee,while判断...
要先用while判断条件,再执行do里面的内容。你先do,后while当然是判断之前就已经把null加上去了。改:while (result!=null){result=patt1.exec("The best things in life are free");document.write(result);}...
这个涉及到逻辑问题因为 当result走到"The best things in life are free“最后的一个e的时候,这时候 result=e,result是有值的然后执行document.write(result);把最后的一个e输入到页面上,会接着往下走,因为result!=null为真,所以while (result!=null...