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 Object-Oriented JavaScript (2015) Constructor Functions and Prototypes Playlist Project

How could the function Playlist work without properties?

at 03:37 on this video, he adds this.songs = []; and this.nowPlayingIndex = 0; but function Playlist doesn't have any property in its parenthesis. How could the function Playlist work without properties in its parenthesis?

Tim Strand
Tim Strand
22,458 Points

i think what you are asking is how can he call Playlist() without any parameters? you dont have to define parameters for a function object to be called. the functions properties are what he is setting by defining this.songs (songs is a property) and this.nowPlayingIndex (also a property of this which is the current instance of Playlist function object.

1 Answer

Thank you Tim! It was a huge help!!!!!!!!