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) Prototypal Inheritance Updating the Song Object

Ronald Hunter
Ronald Hunter
17,474 Points

So "This" is what is happening. ;)

So if I make a new song object called jabbascript. The this property within the constructor function will be the value jabbascript which will then be passed to the media.call(). So the "this" in Media.call( this , title , duration ); is really

Media.call( jabbascript , title , duration );

and media.call() is like media().

and all of the media objects goodies are given to the song object to be used.

ok darius.

1 Answer

Steven Parker
Steven Parker
229,732 Points

The value of this would not be the name of your object, but it would be a reference to the object itself.

So passing this would be equivalent to passing jabbascript (no quotes).

Ronald Hunter
Ronald Hunter
17,474 Points

sorry about the quotes i dont know how to bold the word

Steven Parker
Steven Parker
229,732 Points

For bold, surround the word or phrase with double asterisks (**) or double underscores (__).

Example: **Check this out** becomes Check this out.

If you forget, there's a link to the Markdown Cheatsheet just below where you enter the answer.


:information_source: Also, you might enjoy the Understanding "this" in JavaScript workshop if you haven't seen it already.