【发布时间】:2019-04-06 16:34:12
【问题描述】:
所以我有:
// some function that returns two arrays ..
getArrays() {
return {
arr1: [...],
arr2: [...]
};
}
// and then ..
let arr1 = [];
let arr2 = [];
if (someCondition) {
{ arr1, arr2 } = getArrays();
}
// here we expect arrays, even if they are empty ..
当然,这会引发错误。 这甚至可能吗?
PS:我可以使用默认值并直接调用该函数,但仍然 - 我认为应该可以。
【问题讨论】:
-
只需添加括号
标签: javascript ecmascript-6 destructuring