• @Feathercrown
    link
    English
    510 months ago

    One neat feature is you can compare to both null and undefined at the same time, without other falsey values giving false positives. Although that’s not necessary as often now that we have nullish coalescing and optional chaining.

    • @[email protected]
      link
      fedilink
      210 months ago

      I just tested and Terser will convert v === null || v === undefined to null==v. Personally I would prefer to read the code that explicitly shows that it is checking for both and let my minifier/optimizer worry about generating compact code.

      • @SzethFriendOfNimi
        link
        010 months ago

        Try changing to const === variable. That’s most likely what’s it doing to minimize the risk of accidental assignment.

          • @SzethFriendOfNimi
            link
            110 months ago

            I agree it shouldn’t. But I’ve seen linters that automatically change it since they seem to be forcing practical conventions sometimes.