Actually, it’s 5 4 10 12 2 9 8 11 6 7 3 1 for me, but too lazy to edit the image

  • vrojak@feddit.org
    link
    fedilink
    arrow-up
    0
    ·
    7 days ago

    I recently found out that javascript’s .sort() function, when called without arguments on an array of numbers, converts them all to strings and sorts them alphabetically 🤡

    • ElectricTrombone@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      7 days ago

      I’m a C programmer. My first time writing Javascript and ran into some sort of bug involving a === sign or something. Javascript is a silly language.

        • FourWaveforms@lemm.ee
          link
          fedilink
          arrow-up
          0
          ·
          6 days ago

          The epitomy of irony is a JavaScript developer insisting that some other language is “a fractal of bad design” without immediately acknowledging that JS is weird as hell.

          • Die Martin Die@sh.itjust.worksOP
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            6 days ago

            I like Lua’s design. Separate addition (x+y) and concatenation (x..y) operators ftw!

            Edit: and just, like, everything else about Lua too

      • humorlessrepost@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        7 days ago

        Javascript lets you compare unlike types without extra steps using ==. If you want strict comparison where “2” isn’t 2, use === and !==. Personally, I find that easier than having to parseint or cast every damn thing or whatever c does (strtol?). That said, I have build tools set up to enforce strict comparison because I don’t trust myself or others.