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

Kevin Ohlsson
Kevin Ohlsson
4,542 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
Mohammed Zeeshan
Full Stack JavaScript Techdegree Student 3,299 Points

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