Monads when no regex

  • invalidusernamelol [he/him]
    ·
    edit-2
    3 years ago

    My favorite thing about JS is that it has true and false evaluations that are more guidelines than rules

    Pop quiz:

    Which is true and which is false?

    a) "false" == true

    b) "0" == true

    c) [] == true

    d) " " == true

    (They're all true)

      • invalidusernamelol [he/him]
        ·
        edit-2
        3 years ago

        I still think JS is an incredibly useful language, but god damn is the concept of "truthy" and "falsey" just insane.

        • MoreLikeSexbearLmao [he/him]
          ·
          3 years ago

          I disagree, I think python handles it pretty well. JS just has some pretty bad rules for truthiness.

          In python:

          • numbers are truthy if they're non-zero

          • containers and strings are truthy if they are non-empty

          • a regex result is truthy if it matched something

          • the None object is not truthy

          • custom objects are truthy by default, but you can define the thruthiness function