• bitjunkie@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    20 days ago

    It’s because + is two different operators and overloads based on the type to the left, while - is only a numeric operator and coerces left and right operands to numeric. But frankly if you’re still using + for math or string concatenation in 2025, you’re doing it wrong.

    • Hadriscus@lemm.ee
      link
      fedilink
      arrow-up
      5
      ·
      20 days ago

      I know nothing about javascript, what is wrong with using + for math? perhaps naively, I’d say it looks suited for the job