@afontaine do you think I’m being too silly and pre-optimizing by not wanting an IIFE for perf reasons? It also seems so much ceremony just to hide a few temporary variables from subsequent code 😕? I’d worry my kouhai would see such code and be more alarmed and wary, wondering what dread cause moved me to write something like that, and they’ll be peeved it was nothing more than containing intermediate variable.
But that is of course a solution.
I think there might be a couple good options depending on complexity...
If you don't need to check `bar` or `baz` for errors, etc. inlining here might not be the worst? It can be spaced out in a way that is still _mostly_ readable
const foo = `h(f(), g())`
but at the same time, if you suddenly need to check `bar` and/or `baz` and sanitize values? then your function is hiding temporary variables _and_ error checking logic, which I think is definitely a win
@afontaine right, in my example f and g and h are standins for expressions of arbitrary complexity. The example that prompted the toot:
Yeah I think there's a line here where encapsulating that complexity in a separate function makes a lot of sense. That link is kind of difficult to read (but that might be more of a lack of domain knowledge on my part)
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!