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 JavaScript Objects Loop Through Objects Loop Through an Object's Properties

Alexandra Velez
seal-mask
.a{fill-rule:evenodd;}techdegree
Alexandra Velez
Front End Web Development Techdegree Student 9,313 Points

What's the meaning of prop?

I don't understand the logic behind prop in this challenge.

What is prop? How does prop relate to this challenge? In a previous lesson the concept of prop was introduced, but it's not clear to me what prop is.

script.js
const composer = {
  name: 'Edward Ellington',
  nickname: 'Duke',
  genres: ['jazz', 'swing'],
  instrument: 'piano'
};

for (let prop in composer) {
console.log(prop);
}

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

prop is short for property. It's just a variable that refers to the property keys in an object.

In this code, what's happening is you're declaring what is called a working variable that represents the properties in an object.

It doesn't have to be called prop. There's nothing special about that name other than it is being used to help clarify what the purpose of having that variable is. :-)