ES6 - Use Arrow Functions to Write Concise Anonymous Functions

Why do we need a Anonymous Function and why it is called Anonymous when we are still assigning it to a variable

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

var magic = function() {
  return new Date();
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183

Challenge: ES6 - Use Arrow Functions to Write Concise Anonymous Functions

Link to the challenge:

we use () => {} very often in .map(), . filter(), forEach() later.
Like a one-time function that don’t need special name…

Because the function itself does not technically have a name:

function() {
  return new Date();
}

You are using the function keyword to create a function but you are not giving it a name. If you gave it a name it would look like:

function myFunctionsName() {
  return new Date();
};

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.