函数式编程

let add = (a,b) => a + b;//就是函数式编程,因为a+b只有一行代码,因此省略了{}

 

方法的优化:

sayHello= function(){console.log("hello");}

sayHello(){console.log("hello");}

 

可以嵌套解构表达式一起使用

const p = {name:"jeck",age:20};

const hello = function ({name,age}){console.log(name,age)};//拿到参数的一刻就进行解构

hello(p);//参数依然是对象

上面的hello可以进一步简化:

const hello({name,age}) => console.log(name,age);

posted @ 2019-10-19 16:52  WaterGe  阅读(108)  评论(0编辑  收藏  举报