DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Should single-use functions be named?

I actually mean lambdas and IIFE's.

Also, should they be local, especially if they are very small?

Top comments (3)

Collapse
 
pentacular profile image
pentacular

If the name adds useful nuance which is not obvious from the implementation, then by all means.

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

if it's more than 1 line of code yes, if it's just a 1 liner like regex and lambdas then it should be ok to not name it. But it should clear for anyone who comes in to maintain your code.

Collapse
 
itsjzt profile image
Saurabh Sharma

Imo If they are inline its fine not to name them.