DEV Community

Discussion on: Why I avoid `get`-like functions in JS

Collapse
 
reyronald profile image
Ronald Rey

Without a function that can pick properties from an object and set good defaults, you can't compose the workflow.

That doesn't mean that the function has to be dynamic in nature and not statically analyzable, and that applies to what you said in the paragraph above as well.

The dynamic approach will likely be shorter, sure, but it's a trade-off. You are trading a preferred code structure for fewer compile time guarantees.

If that's a trade-off a team is comfortable doing or it makes sense for a given problem regardless for whatever reason, then by all means.

Collapse
 
timhlm profile image
moth

True, that’s a great point. Thanks for writing this!