• bleistift2@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    33
    ·
    1 day ago

    I am a frontend dev. JavaScript (well, TypeScript) is my bread and butter. Even knowing its quirks I never would have thought how inconsistent Date actually is. I encourage everyone to try this quiz.

    This is what JavaScript haters should bring forth, not 0.1 + 0.2 !== 0.3!

    • dalekcaan@feddit.nl
      link
      fedilink
      arrow-up
      2
      ·
      11 hours ago

      Or the ones where people point out how inconsistent JS is with adding strings to numbers.

      Yeah, maybe don’t do arithmetic on numbers as strings?

    • Hotzilla@sopuli.xyz
      link
      fedilink
      arrow-up
      21
      ·
      1 day ago

      Floating point rounding issues are basic comp science issues. Hopefully nobody thinks that those are JavaScript quirks.

    • Tanoh@lemmy.world
      link
      fedilink
      arrow-up
      11
      ·
      1 day ago

      There is a reason almost everyone use some Date lib, like Luxon and not the built in. And well, having a horrible built in lib that they can’t change due to legacy code breaking is nothing really new or unique to JS.

      • bleistift2@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        2
        ·
        11 hours ago

        The built-in lib is fine for basic stuff unless you do some crazy shit like expecting "2" to parse as a valid date.

        • Tanoh@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          9 hours ago

          For very basic things maybe, but it has a lot of other weird problems and restrictions. Mutability, no real timezone support, very limited arithmetic, to name a few. As soon as you move beyond the very basic, you want someting more robust.