• Victor@lemmy.world
      link
      fedilink
      arrow-up
      19
      arrow-down
      15
      ·
      1 year ago

      Classic people who don’t know how to code wat. Passing a number in place of a string argument because they don’t know what they’re doing.

      • jjjalljs@ttrpg.network
        link
        fedilink
        arrow-up
        32
        arrow-down
        3
        ·
        1 year ago

        Javascript could throw an error to alert you that the input is supposed to be a string, like most languages would do.

        • Victor@lemmy.world
          link
          fedilink
          arrow-up
          3
          arrow-down
          5
          ·
          edit-2
          1 year ago

          But you’re calling a function specifically made for passing a string to an int… 😆 There’s gotta be some common sense somewhere here, guys.

          Still, it’s a very good point. JS should do this.

          I would suspect one reason it doesn’t do this is to be backwards compatible.

        • heavy@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          7
          ·
          1 year ago

          Theoretically, Javascript is an untyped language, so there aren’t supposed to really be static types. Giving type errors in this situation would be against design.

      • qqq@lemmy.world
        link
        fedilink
        arrow-up
        11
        ·
        edit-2
        1 year ago

        Could be a variable from somewhere else in the code. It should throw type error of some sort if it’s not going to handle a float correctly

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

          Agreed, functions in general should do this, and some do. But it should probably be automatic. And the variable argument is a good one, a very good argument for TypeScript. ❤️