<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>break与continue</title> <!-- //break:当n=4时终止for循环 //continue:当n=4时不执行代码块,在n=5时继续执行代码块 for (var n=0;n<10;n++){ if (n=4){ break/continue; } document.write(n);//代码块 } --> </head> <body> <script> var i; while (i!=123456){ i=prompt("请输入密码"); } while (i=123456){ i=prompt("请再次输入密码") if (i!=123456){ continue;//跳过本次,继续下次循环 }else if(i=123456){ alert("两次输入的密码一致"); break;//不再执行循环 } } </script> </body> </html>