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 Understanding "this" in JavaScript

Carlos Villarroel
Carlos Villarroel
23,748 Points

Using the Arrow Syntax

I got the methods to work fine, but when I write the functions with the arrow syntax I get 'undefined' logged to the console. Does anyone know why that is?

1 Answer

Steven Parker
Steven Parker
231,186 Points

Arrow functions do not deifne "this".

Since you're working with the Understanding "this" in JavaScript workshop, I assume "this" is being used in your functions. But one difference between conventional and arrow functions is that arrow functions do not define "this", so they might not be a good choice for what you are implementing.

This (no pun intended) and other differences are described in the MDN documentation page on Arrow Functions.