重设const变量,即使它是const(ES6)

问题描述 投票:0回答:1

我想我刚刚在es6中发现了一个错误。

const { response } = somecall();
if (response) {
   const { response } = someOtherCallThatReturnsUndefined(response);
   // the value of response being passed in to **someOtherCallThatReturnsUndefined** is actually undefined
}
javascript ecmascript-6
1个回答
0
投票

通过说const { response },您是在与原始变量不同的上下文中声明变量,因此您可以这样做。

© www.soinside.com 2019 - 2024. All rights reserved.