我想我刚刚在es6中发现了一个错误。
const { response } = somecall();
if (response) {
const { response } = someOtherCallThatReturnsUndefined(response);
// the value of response being passed in to **someOtherCallThatReturnsUndefined** is actually undefined
}
通过说const { response }
,您是在与原始变量不同的上下文中声明变量,因此您可以这样做。