Javascript 函数参数的一种有趣写法
最近,我见到下面这样的Javascript函数写法:
function hello({name, title}){
console.log(`Welcome the ${title} ${name}`)
}
// call it.
const param = { name: 'Jack', title: 'Developer', company: 'LabX'}
hello(param);
上面这种函数定义方式,相当于
function hello(params){
const {name, title} = params
//...
}
这样看起来就更容易理解了。