ES6 - Use Arrow Functions to Write Concise Anonymous Functions

I dont understand this lesson. Why would someone write a function that has no body and just a value? Wouldn’t that just be a variable?

const myFunc = () => "value";

VERSUS

const myFunc = "value";

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

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

Link to the challenge:

The function…

const myFunc = () => 'value';

…is functionally the same as this.

const myFunc = () => {
  return 'value';
};

The first has an implicit return and the second has an explicit return.


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