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

Kevin Ohlsson
Kevin Ohlsson
4,559 Points

Are arrow function anonymous functions ?

hello

are arrow functions anonymous functions?

anonymous fucntions are function that does not have a name, right?

i cant name arrow functions?

3 Answers

Yes, arrow functions are anonymous. Arrow functions, by default, do not have a name. This makes it easy to just make a function and pass it immediately into another function. But, you can give them a name if you wish. Of course, there's no special way of doing it, unlike the function keywordβ€”it's just by simply assigning the arrow-function to a variable.

// All the below lines are identical
function add(x, y) { return x + y; }
const add = function(x, y) { return x + y; };
const add = (x, y) => (x + y);
Mohammed Zeeshan
PLUS
Mohammed Zeeshan
Courses Plus Student 3,302 Points

That sounds strange but can you share behind-the-scenes so i can get it known thorougly