Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

After spending a lot of time writing idiomatic React components in es6, I've found my love of locally declared lambdas to really grow. If I give the lambdas really good names, I find that the main body of my component is very, very readable, even more so than if I'd used a more traditional style liberally sprinkled with comments.


> If I give the lambdas really good names

That's a really funny way to say it.


Giving your lambdas names defeats part of their purpose though.


They have two distinct purposes: anonymous functions, and closures. Those often go together, but there are many scenarios where you only care about the latter, and don't actually need the former. Named lambdas (i.e. lambdas assigned to local consts) covers this case if the language doesn't have dedicated syntax for it.


maybe one purpose. but it fulfills another purpose- self-documenting code, and a really simple non-nested main body to your function.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: