晴明的博客园 GitHub      CodePen      CodeWars     

[javascript] ECMAscript6

let

可替代 var 声明变量,但 let 声明的变量只在它所在的代码块有效。

特别适用于 for()循环中。

-------------------------------------------------这是分割线 --------------------------------------------------------------------------------

const

声明常量,常量无法被改变。

-------------------------------------------------这是分割线 --------------------------------------------------------------------------------

箭头函数(=>)

  function friend = friends => friends.filter(friend => friend.length == 4);

相当于

  function friend(friends) {
    return friends.filter(function(friend) {
      return friend.length === 4;
    });
  }

-------------------------------------------------这是分割线 --------------------------------------------------------------------------------

 

posted @ 2016-02-04 11:40  晴明桑  阅读(82)  评论(0编辑  收藏  举报