JavaScript学习笔记2分享

JS的流程控制

分支结构

  • if-else
  • switch-case

    swith (score){

       case 1:{

        }

        break;

       case 2{} break;

      default:{

       }

    }

循环语句

  •      while
  • for (var i =1;i<100;i++){}

中断和跳转

  • break
  • continue 继续

异常

throw “ throw it error ”

 

函数

  • 常用函数

 

function yourfunctionName(name){

//todo funciton

return name;

 }

  • 用函数表达式定义函数

    var  outputAge=funciton(age){

        console.log("马云  is" +age); 

   }

  outputAge(25);//结果是马云  is 25

  var mathFunc=function mathF(a) {

     var res=a;

      a--;

      if (a>0) {

      res*= matchFunc(a)

     }

     return res;

   };

var   mathRes=mathFunc(5)

console.log(mathRes) //   5*4*3*2*1=120

 

 

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值