• 23 Posts
  • 239 Comments
Joined 1 year ago
cake
Cake day: June 2nd, 2024

help-circle












  • bleistift2@sopuli.xyztoProgrammer Humor@lemmy.mlTrue crime
    link
    fedilink
    English
    arrow-up
    33
    ·
    1 month ago

    The logic is fine. If you rename the variable to isAdmin, it makes perfect sense. Either they are an admin, or they are not an admin, or the state is unknown (here expressed as null). If you want to throw another JS-ism at this, undefined could be assigned before the check has been made.

    I regularly use variables like this. If users is undefined, I haven’t fetched them yet. If they’re a list, then fetching is complete. If they’re null, then there was an error while fetching.