Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Crystal Vesely
Crystal Vesely
14,500 Points

Is the naming of {side} variable just a name chosen or is it a property of the req.query object?

const {side} = req.query is equivalent to const side = req.query.side

So does that mean the req.query has a side property that we’re accessing or are we choosing a variable name and creating a side property on the object?

If feel like we are creating a property on the object and are setting that value to the variable through the url query string. Am I correct?

1 Answer

Steven Parker
Steven Parker
231,275 Points

Yes, "side" is a property of the req.query object, and it is also the chosen name of the new variable. The difference is that the syntax of the first example uses destructuring to access the property with the same name as the new variable.

For future questions, it would help to know what course and lesson you are referring to. You might want to take a look at this video about Posting a Question.