DEV Community


Discussion on: Tips on naming boolean variables - Cleaner Code

mattgic profile image
Matthieu L.

Great article, thanks !
Question, how do you name boolean getters ?
I've seen people using booleans like "empty" and getters like "isEmpty()", but I prefer having is/has prefixes for booleans as you say.
I use getters like "getIsEmpty()" for an "isEmpty" boolean, but many people find it akward..

crhain88 profile image
Christian • Edited

I prefer to leave verbs for functions, such as getters.

let empty = true;

const isEmpty = () => empty;
const getEmpty = () => empty;
Enter fullscreen mode Exit fullscreen mode
stepanstulov profile image
Stepan Stulov

Many people do but stand your ground, it's good.