How to destructure an object?

Continuing the discussion from JAVASCRIPT SYNTAX, PART III Message Mixer:

Welcome to the Get Help category!

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!

Could you specify how the rather general question from your title is related to the topic you linked?
The question ‘How to destructure an object?’ is answered quickly and independently from the linked topic:

basic object destructuring

const obj = {
	str: 'a string'
}
const {str} = obj;
console.log(str); // logs: 'a string'

nested object destructuring

const obj = {
	nestedObj: {
  	str: 'a string'
  }
}
const {nestedObj: {str}} = obj;
console.log(str); // logs: 'a string'

Does this already answer your question?

Yes it does! Thank you.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.