• TimeSquirrel@kbin.social
      link
      fedilink
      arrow-up
      18
      ·
      edit-2
      1 year ago

      Normal languages: “does this equal that?”

      JS: “does this REALLY equal that, or just ‘equal’ that?”

          • Wrench@lemmy.world
            link
            fedilink
            arrow-up
            4
            ·
            1 year ago

            No one checks those values explicitly.

            if (str) checks if it’s not null, undefined, or empty string.

            Optional chaining like if (arr?.length) checks if list is undefined, null, or empty array.

            Falsy and truthy comparators seem fucky in the beginning when coming from a strongly typed language. But they’re very convenient when used properly.

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

              Monads exist, optional chaining has been around for ages, and implicit bool casts, too.

              As you said, no one checks those values explicitly.