I don't chain everything in JavaScript anymore
Posted by AllThingsSmitty 1 day ago
Comments
Comment by t0mpr1c3 20 hours ago
Comment by plumbees 1 day ago
Comment by plumbees 1 day ago
Comment by shaftway 20 hours ago
But I'm in the same boat. I love the expressiveness of chaining a whole thing into a single call, but I have to break it apart for my own sanity.
Comment by prismatix 1 day ago
Comment by mekoka 1 day ago
Comment by efilife 23 hours ago
Comment by joshstrange 1 day ago
It's the same reason I don't like this style of function:
.map(var => var.toUpperCase())
Sure, it's great today but but I want to debug it I need to add `{}` in and/or if I need to add a second operations I need to add the curly braces as well. That's I prefer explicit: .map((var) => {
return var.toUpperCase();
})
Since it's much easier to drop in a debug line or similar without re-writing surrounding code. It also makes the git diff nicer in the future when you decided to do another operation within the `.map()` call.I've asked many people to re-write perfectly functioning code for this same reason. "Yes, I know you can do it all in 1 line but let's create variables for each step so the code is self-documenting".
Comment by nottorp 1 day ago
Comment by khelavastr 21 hours ago
This is a solution that people fixed 25 years ago with detailedReturnObjectNames.
Comment by jfengel 3 hours ago
I'd expect that much of the time, the return variable is closely linked to the name of the function. So closely linked that it risks being redundant.
Comment by tears-in-rain 1 day ago