ES6初识-函数扩展

  • 默认值
function test(x,y='world'){
console.log('默认值');
}
function test2(...arg){
for(let v of arg){
console.log("rest",v);
}
}
test2(1,2,3,4,5,'a');
 
  • 箭头函数
let arrow =v=>v*2;
console.log('arrow',arrow(3));//6
  • 尾调用---性能优化的过程中,嵌套过多
function tail(x){
console.log('tail',x);
}
function fx(x){
return tail(x);
}
fx(123);
posted @ 2017-11-26 22:26  浮云随笔  阅读(143)  评论(0编辑  收藏  举报