Javascript 重构-解构语句

Javascript 重构-解构语句,javascript,ecmascript-6,Javascript,Ecmascript 6,重构上述代码段以使用解构 const question = this.props.question const answer = question.answer 如何将此分解结构重构为一行? 如果我这样做,const{question:{answer}}}=this.props,我就不会得到question?在解构时可以多次引用同一属性: const { question } = this.props const { answer } = question const props={ 问题

重构上述代码段以使用解构

const question = this.props.question
const answer = question.answer
如何将此分解结构重构为一行?
如果我这样做,
const{question:{answer}}}=this.props
,我就不会得到
question

在解构时可以多次引用同一属性:

const { question } = this.props
const { answer } = question
const props={
问题:{
回答:“回答”
}
};
常量{问题,问题:{答案}}=道具;
控制台日志(问题);
控制台日志(应答)
const { question, question: { answer } } = this.props;