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!

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 Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Modifying Elements

Michal Janek
.a{fill-rule:evenodd;}techdegree seal-36
Michal Janek
Front End Web Development Techdegree Graduate 30,654 Points

How to use arrow function syntax in this course?

I am asking because up to this point my code worked but when Andrew introduced his first "this" thingy, the whole thing just didn't wanna work. It probably has something to do with the fact that arrow syntax does not have defined "this". Any ideas to work around this? I really do not want to use var xy =function () { } That is just lame now.

1 Answer

Simon Coates
Simon Coates
28,694 Points

I just did a demo that seemed to work (i'm new at JS so i hope i'm not missing anything) in which the arrow function expected the event, and used ev.target instead of this. The fragment resembled:

const deleteTask = (ev) => {
  console.log("Delete txask...");
  var listItem = ev.target.parentNode;
  var ul = listItem.parentNode;

  //Remove the parent list item from the ul

Does this help at all?