upvote
This is a statement vs expression thing. It works as an expression. Try:

    f = function (v) { return e ; }
or

    (function (v) { return e ; })
Javascript doesn't allow (nameless) function expressions (using the function keyword) where a function statement would work.

(and that particular function can also be written v => e)

As for the e being undefined when you execute the function, you should see it as a free variable [1], supposed to be defined elsewhere or replaced with something else.

[1] https://en.wikipedia.org/wiki/Free_variables_and_bound_varia...

reply
Good point -- JavaScript's syntax grew up since I wrote that article!
reply
It's meant as an example. The function receives something, which we call v, and returns something else, which we call e. It's not meant to be taken literally as the variable names - otherwise, you are right, e is undefined in that example.

He is just showing how the syntax of a Scheme function corresponds to the structure of a JavaScript function.

reply
Its just an example. It doesn't matter what the function name is. And it doesn't matter where e comes from. No need to include it
reply