Comment

Comment by jraph

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...

parent jraph 5 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton