在javascript函数声明中声明对象中的变量时,调用什么?

在javascript函数声明中声明对象中的变量时,调用什么?,javascript,function,Javascript,Function,我最近了解了这个很棒的方法,它使用一个预设默认值的对象来声明函数的变量。这个方法有名字吗 function test({var1= 'hello', var2= 'world'} = {}) { console.log(var1, var2); } test(); // result 'hello world' test({var2: 'universe'}) // result 'hello universe' 我也不知道为什么它要求对象为“={}”这被称为参见为这个特殊情况设置函数参数的默

我最近了解了这个很棒的方法,它使用一个预设默认值的对象来声明函数的变量。这个方法有名字吗

function test({var1= 'hello', var2= 'world'} = {}) { console.log(var1, var2); }
test(); // result 'hello world'
test({var2: 'universe'}) // result 'hello universe'

我也不知道为什么它要求对象为“={}”

这被称为参见为这个特殊情况设置函数参数的默认值一节^特别是这两节:和