DEV Community

Discussion on: Functional Programming in JavaScript? Yes, Please.

Collapse
 
juni profile image
Junaid Anwar

Nice article, I have a question that why did you define the function twice in the first code block?

Function double(x)
And
Let double = function(x)

Collapse
 
tiffany profile image
tiff • Edited

One is a function declaration:

function double(x)

or named function. The other is a function expression
let double = function(x)

or anonymous function.

I declared each to show how easy it is to reassign a value with an anonymous function.