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 JavaScript and the DOM (Retiring) Getting a Handle on the DOM A Simple Example

Leo Penaloza
Leo Penaloza
8,426 Points

Is this code literal or symbolic?

myHeading.addEventListener("click",() => { myHeading.style.color="red"; });

Since it's "=>", is that suppose to represent an arrow or is it greater than and equal to?

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there, Leo Penaloza ! Yes, that code is literal. The () => is called "arrow syntax" and is part of ES6. In this case, it is an anonymous function that has no parameters.

I might suggest taking a look at this 49 minute course on getting started with ES2015. If you're looking for information on arrow syntax only, try this 8 minute workshop specifically about arrow syntax.

Hope this helps! :sparkles:

28,558 Points

It is literal code, and it is supposed to look like an arrow. It is an example of an Arrow Function which is a type of function that was added in ES6. Treehouse does have a short workshop dedicated to it here that you can watch if you want to learn more about it.

Though if you have not been introduced to any ES6/ES2015 concepts like let, const and arrow functions then I would actually recommend that you complete the Getting Started With ES2015 course first. As knowledge of ES6 features is assumed in the "JavaScript and the DOM" course, as well as in many other Treehouse JavaScript courses.