javascript let

es6支持通过let关键字声明属于单独块{}的变量,更好的管理变量作用屿

funtion foo() {

  var a=1;

  if (a>1) {

    let b=2; //只属于if模块

    while(b<5) {

      let c=b*2;cc只属于while循环

      b++;

      console.log(a+c)

    }

  }

}

foo()

原文地址:https://www.cnblogs.com/agang-php/p/11449495.html