• Wrench@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      10 months 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.