javascript基本教程的中断和继续语句

javascript基本教程的中断和继续语句
break和continue语句提供更严格的过程在循环执行代码的控制。break语句可以立即退出循环,防止代码执行一次循环体中,continue语句只是退出当前循环,使下一个周期是根据控制表达式进行。

打破

复制代码代码如下所示:
var =新的数组(大量);

无功smessage =你输入:;

var ITOTAL = 0;

无功vuserinput;

无功iarrayindex = 0;

做{

vuserinput =数(提示(输入一个数,或'0'exit

如果(isnan(vuserinput)){

document.write(输入错误,请输入数字,'0'exit );

中断;直接输入错误。

}

大量iarrayindex } = { vuserinput;

iarrayindex + +;

}而(vuserinput!= 0)当输入退出循环体时输入为0(默认值)

通过循环遍历数组的常用方法:

对于(var i = 0;i < anumbers.length;i++){

ITOTAL =数(大量{我});

smessage =大量{我} + ;

}

smessage =总:+ ITOTAL;

document.write(smessage);
继续

复制代码代码如下所示:
var =新的数组(大量);

无功smessage =你输入:;

var ITOTAL = 0;

无功vuserinput;

无功iarrayindex = 0;

做{

vuserinput =数(提示(输入一个数,或'0'exit

如果(isnan(vuserinput)){

警报(输入错误,请输入数字,'0'exit );

继续;输入错误退出,继续到下一个循环。

}

大量iarrayindex } = { vuserinput;

iarrayindex + +;

}而(vuserinput!= 0)当输入退出循环体时输入为0(默认值)

通过循环遍历数组的常用方法:

对于(var i = 0;i < anumbers.length;i++){

ITOTAL =数(大量{我});

smessage =大量{我} + ;

}

smessage =总:+ ITOTAL;

document.write(smessage);
这些人知道这2种说法之间的区别和联系吗

tag:教程语句中断电脑软件Javascript

相关内容