JavaScript条件语句

if语句

if...else语句

if...else if...else语句

if(xxx) 当xxx是0  undefined  null  ""  NaN时 ,为false。

if后面只有一条语句时,大括号可以省略。

switch语句

注:如果不写break的话,会从第一个符合条件的case进入,下面的case都会执行

var total = 0;

switch(3){

  case 4:

  total+=4;

  case 3:

  total+=3;

  case 2:

  total+=2;

}

结果total为5。

posted @   盗哥泡茶去了  阅读(126)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示