DEV Community

Discussion on: All you need to know about Javascript's Expressions, Statements and Expression Statements

Collapse
 
paxfeline profile image
David Newberry

The code has one too many "foo"s, it should be:

const foo = () => {
assignedVariable = 14
}

() => { ... } is an anonymous function, which is then assigned to const foo.

The other code:
foo(function () {} );
also uses an anonymous function (using different syntax). This code would mean call the function "foo" and pass an anonymous (and empty) function.