-
箭头函数(匿名函数)
1
2
3
4
5
6
7
8
9
10var s = function (pp){
return "function"
}
// 替换成现在这样
(pp)=>{return "function"}
// 可以简写为下面这样(“()”, 当参数为一个时,可省略, “{}”, 当语句为一条时, return 也可省略)
pp => "myfunction" + pp
// 假如需要返回一个对象
(pp)=>({"name": "function"})
// 能够对this 进行 -
循环
- for (var i in arr){} // i 为 索引/键
- for (var i of arr){} // i 为 值,arr 不可为对象
- for (var i;i<10;i++){}
- while (i > 10){}
- do {}while(){} // 循环之前先执行 do 里面的语句(不常用)
-
遍历数组
- forEach((index, item, items)=>{}, thisValue);
- arr.map((index, item, items)=>{}, thisValue);
-
新增数据类型(Map, Set)
近期评论