Why the anonymous function look almost like an arrow functionn?

why the anonymous function look almost like an arrow functionn ?
and how do we invoke them ?

I get confuse of arrow function anonymous function and function expression. Is there any different about them ?

An anonymous function is one with no name, meaning it is an expression.

const foo = expression

where expression can be any of,

... = function (bar) {
    return bar
}

or,

... = (bar) => {
    return bar
}

or,

... = bar => bar;

When the input of a function is the return value of another, we can write the function expression directly in the argument…

function faz(bar => bar)

The argument in the above is an anonymous function.

1 Like

how can I call a a anonymous function when it has no name

Assign it to a variable, then invoke the function with that.

const foo = function (bar) {
    return bar
}

console.log(foo('bar'))    //  bar
1 Like