const a = {在上面的示例中,变量
开始:{x:5,y:6},
结束:{x:6,y:-9}
};
const {start:{x:startX,y:startY}} = a;
console.log(startX,startY); // 5,6
start
被赋予a.start
的值,该值也是一个对象。 max
的forecast.tomorrow
并将其分配给maxOfTomorrow
。 maxOfTomorrow
等于84.6
testString: 'assert(getMaxOfTmrw(LOCAL_FORECAST) === 84.6, "maxOfTomorrow
equals 84.6
");'
- text: 使用嵌套解构
testString: 'getUserInput => assert(getUserInput("index").match(/\{\s*tomorrow\s*:\s*\{\s*max\s*:\s*maxOfTomorrow\s*\}\s*\}\s*=\s*forecast/g),"nested destructuring was used");'
```