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 Vue.js Basics Building a Flashcard App Creating a New Card

Alex Hort-Francis
Alex Hort-Francis
17,074 Points

'this' keyword: why is it used here?

At 2:00 in the video.

We create a function to add a new card. Why do we need to use:

...
front: this.newFront, 
back: this.newBack,
...

... as opposed to:

...
front: newFront, 
back: newBack,
...

Is this because the second option would be interpreted by Javascript as 'newFront' & 'newBack' referring to variables that are being defined within the scope of the function itself?

Thanks, Alex