top | item 37126579

(no title)

polack | 2 years ago

The real question is why they do Module.function() and then function.() instead of .function()?

It makes no sense to have the dot at the end of an anonymous named function.

discuss

order

sodapopcan|2 years ago

`function()` is stored inside a `Module`, so we call `Module.function()`.

An anonymous function "`()`" is stored inside a `variable`, so we call `variable.()`.

It does make some good sense. It's even kinda elegant!

darraghenright|2 years ago

I've sometimes wondered if I am the only person who actually likes the syntax :D There's a reason for it, but additionally, I like the fact that it's explicit — I can look at `some_call.()` and specifically know it's an anonymous function.

brightball|2 years ago

When it's explained that way, it makes a lot of sense.