• lemmy_see@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      1 year ago

      “Other alternatives” is a pleonasm, “alternatives” suffices.

      We should make a linter for Lemmy. That’ll shut me up.

      • Phen@lemmy.eco.br
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        Except you can add the key with an undefined value and it may have different behaviors than if the key was really not there.

          • activ8r@sh.itjust.works
            link
            fedilink
            arrow-up
            2
            arrow-down
            1
            ·
            edit-2
            1 year ago

            In JS a Boolean has 4 states.
            true
            false
            undefined (where the key is set to undefined)
            undefined (where the key doesn’t exist on the object)

            if (obj.value === true) {  
                console.log(1);
            } else if (obj.value === false) {
                console.log(2);
            } else if ("value" in obj) { // key "value" is in the obj, but it is set to undefined 
                console.log(3);
            } else { // key "value" is not in object
                console.log(4);
            }
            

            You’re welcome.