Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Thomas Katalenas
11,033 Pointsplaylist instead of Playlist constructor? but why..
around the 7:10 to 7: 30 duration in the video
we can see the code uses
playlist.play
playlist.next
playlist.stop
yet in the playlist.js file it is clear to see that the constructor is Playlist with a capital P as seen below. is this referenceing the playlist.js file is that why it is lower case?
Playlist.prototype.play = function() {
var currentSong = this.songs[this.nowPlayingIndex];
currentSong.play();
};
Playlist.prototype.stop = function(){
this.stop();
this.nowPlayingIndex++;
if(this.nowPlayingIndex == this.songs.length){
this.nowPlayingIndex = 0;
};
this.play();
};
1 Answer

Jennifer Nordell
Treehouse TeacherNo. In app.js on the first line at the start of the video you have this line:
var playlist = new Playlist();
This creates a new instance of a Playlist object which will now be referenced to simply as playlist
. In reality, you could have named this any valid JavaScript variable name. For example, myPlaylist
or yourPlaylist
. Those would then be referenced by those names.
Hope this helps!