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

The "This" Keyword with Arrow and Normal Fuction

While using the 'this' keyword on my methods, With arrow functions I'm not able to access object properties from within the method. But when I use the this keyword with a normal function I am able to access the object properties.

Can someone try to give what is precise with arrow functions and the 'this' keyword?

2 Answers

Steven Parker
Steven Parker
231,141 Points

As you have discovered, arrow functions don't establish "this" as conventional functions do, so they are not always a suitable replacement.

There are other differences as well, for complete details on them all see this MDN page on Arrow function expressions.

Thanks Steven.

That was unintentional Steven.

Thanks for the heads-up.