generator函数;
定义
function* foo(){
....
yield x1;
....
yield x2;
........
return xn;
}
调用
var f=foo();
f.next() //x1,false
f.next() //x2,false
.
.
.
f.next() //xn,true
可以不断返回值,并且在执行的时候,返回一次就暂停,直到下次调用
箭头函数
特点:词法作用域;
x=>x+x
相当于
function(x){
return x+x;
}
参数为空
()=>{};
多参数
(a,b,...rest)=>{};
返回单属性的对象
()=>({a:1})