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

Nicholas Lansing
Nicholas Lansing
8,901 Points

explain the new Profile

can someone help explain the line var studentProfile = new Profile("..")? This part isn't explained in the video (unless I missed it somewhere). Seems like the Profile is an object that we are creating?

Thanks for the help!

1 Answer

Steven Parker
Steven Parker
229,783 Points

You're exactly right. That code creates a new object of the Profile class and calls it studentProfile.

The "Profile" class is defined in the separate module named "profile.js".

Nicholas Lansing
Nicholas Lansing
8,901 Points

I can see the function there, but I guess where I got confused was that Profile is declared as a function and not as a class which is why I hadn't seen before. I guess I may just need to get a better understanding of classes... But thank you for the help!

Steven Parker
Steven Parker
229,783 Points

The "class" syntax and keyword is a recent addition to the language. The previous convention (which is still valid) is to use the "new" keyword to call a named constructor function to create an instance.

Nicholas Lansing
Nicholas Lansing
8,901 Points

ahh thank you for that! That would explain it then, I will check out constructor functions to understand declaring classes this way. Thanks!