JavaScript JavaScript and the DOM Getting a Handle on the DOM A Simple Example

Kevin Ohlsson
Kevin Ohlsson
4,546 Points

Are arrow function anonymous functions ?


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
Mohammed Zeeshan
Pro Student 3,301 Points

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