• marcos@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      2 hours ago

      There are several small details that PHP won’t allow, but It’s valid Javascript and it’s the kind of thing you may find on that language.

    • normalexit@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      17 minutes ago

      Product manager: “I want a new role for users that can only do x,y,z”

      Developer: “uh… yeah. About that… Give me a few days.”

    • shape_warrior_t@programming.dev
      link
      fedilink
      English
      arrow-up
      14
      ·
      3 hours ago

      I would certainly rather see this than {isAdmin: bool; isLoggedIn: bool}. With boolean | null, at least illegal states are unrepresentable… even if the legal states are represented in an… interesting way.

    • Drewmeister@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      edit-2
      5 hours ago

      E: omg forget my whole comment. I agree with you that the name sucks.


      I mostly don’t like that role is typically an intuitive name, and now suddenly it means something I wouldn’t expect. Why add confusion to your code? I don’t always remember what I meant week to week, much less if someone else wrote it.

      • dohpaz42@lemmy.world
        link
        fedilink
        English
        arrow-up
        6
        ·
        5 hours ago

        If I had a nickel for every time that happened to me, I’d still be poor, but at least I’d have several nickels. 😁

  • katy ✨@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    27
    arrow-down
    3
    ·
    6 hours ago

    i would say why would you just not to isAdmin = true but i also worked with someone who did just this so i’ll instead just sigh.

    also the real crime is the use of javascript tbh

      • Maiq@lemy.lol
        link
        fedilink
        arrow-up
        4
        ·
        4 hours ago

        Was looking at it and could not figure out why their weren’t any semicolon’s.

        • ScintillatingStruthio@programming.dev
          link
          fedilink
          English
          arrow-up
          6
          ·
          2 hours ago

          Neither Javascript nor Typescript require semicolon, it is entirely a stylistic choice except in very rare circumstances that do not come up in normal code.

          • Ephera@lemmy.ml
            link
            fedilink
            English
            arrow-up
            2
            ·
            44 minutes ago

            Hmm, a webdev colleague said he’d normally prefer without semicolons, but used them anyways for better compile errors.

          • Lemminary@lemmy.world
            link
            fedilink
            arrow-up
            4
            ·
            edit-2
            1 hour ago
            Explanation for nerds

            The reason is the JS compiler removes whitespace and introduces semicolons only “where necessary”.

            So writing

            function myFn() {
              return true;
            }
            

            Is not the same as

            function myFn() {
              return 
                true;
            }
            

            Because the compiler will see that and make it:

            function myFn() { return; true; }
            

            You big ol’ nerd. Tee-hee.

            • Ephera@lemmy.ml
              link
              fedilink
              English
              arrow-up
              2
              ·
              42 minutes ago

              That’s terrifying, especially in JS where no type system will fuck you up for returning nothing when you should’ve returned a boolean.

          • Maiq@lemy.lol
            link
            fedilink
            arrow-up
            3
            ·
            2 hours ago

            That’s good to know. Don’t know how I didn’t know this. Been writing JS since 2000. Always just used them I guess. Ecmascripts look funny to me without them

  • DreamButt@lemmy.world
    link
    fedilink
    English
    arrow-up
    16
    ·
    6 hours ago

    This is pretty clearly just rage bait. Nothing is actually setting the value so it’s undef. Moreover there isn’t any context here to suggest if the state definitions are determined by some weird api or are actually just made up

      • Björn Tantau@swg-empire.de
        link
        fedilink
        arrow-up
        18
        ·
        5 hours ago

        Ackshually three equal signs check for type as well. So mere truthiness is not enough. It has to be exactly true.

        Also, everyone knows FILE_NOT_FOUND isn’t a string but a boolean value.

  • 9point6@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    5 hours ago

    role is never instantiated, so the… privileged…logs… will never be called

    Edit: Actually no logs at all, I read the null as undefined on first skim