Need of anonymous function?

Tell us what’s happening:

In this problem they are clearly using the function again. So, what is the need of an anonymous function if not to create a function which will only be fun once.
They could have just created function normally right?

function greeting(name = "Anonymous"){
    return "Hello " + name;
}


**Challenge:**  Set Default Parameters for Your Functions

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions

This is not an anonymous function. This is a normally created function. It only has “Anonymous” as a default argument.

I would consider arrow functions to be anonymous function expressions.

Assigning a function expression to a variable is not the same as naming it. But they obviously can have names you can invoke them with. MDN uses the semantic implicit names compared to a named function expression which is an explicit name (MDN: Named function expression).

Not sure how accurate the semantics is but the shape of an arrow function does suggest it’s a concise anonymous function expression.

const anonymousFunctionExpression = function() {
}

const namedFunctionExpression = function someFnName() {
}

const anonymousFunctionExpressionArrowFn = () => {
}

But I doubt that is what was asked about anyway.

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