JavaScript JavaScript and the DOM 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",() => {"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 Staff

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,431 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.