• LiPoly@lemmynsfw.com
    link
    fedilink
    arrow-up
    21
    ·
    16 days ago

    Tell me you’re a JavaScript StackOverflow copy-pasta noob without telling me you’re a JavaScript StackOverflow copy-pasta noob.

  • tatterdemalion
    link
    fedilink
    arrow-up
    13
    ·
    16 days ago

    This type of shit makes me aware that there really are devs that don’t care about efficiency and will spend weeks on some really novice shit because their tools and skills are bad.

  • Scoopta
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    17 days ago

    I don’t get it? When has this ever fixed a bug? Compiler error sure? But a bug?

    • Gamma@beehaw.org
      link
      fedilink
      English
      arrow-up
      8
      ·
      16 days ago

      I actually had a bug in a game jam freshman year because of this. It was java, so there was a lot of questionable decisions going on, but adding the semicolon fixed it!

      • Scoopta
        link
        fedilink
        arrow-up
        3
        ·
        16 days ago

        …I want details. Java is my most used language and I want to know lol

        • Gamma@beehaw.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          15 days ago

          … now that I’m thinking harder it may have been a colon? The real problem was that we’d only been programming a few months at that point and were pretty good at accidentally fucking up syntax

          • Scoopta
            link
            fedilink
            arrow-up
            1
            ·
            15 days ago

            Ah, I mean syntax issues trigger compiler errors though. I’m not sure of one that compiles but has odd behavior… except the increment/decrement operators. Maybe I’m just not remembering one

    • Eranziel@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      16 days ago

      Semicolons are technically optional in JS, but there are some rare cases where omitting them can result in different behaviour.

      And this is why you should enforce code style, kids. Preferably with an automated tool.

      • Excigma@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        13 days ago

        I’m on my phone rn so can’t format well, but one such example is:

        const thing = require(“module”)

        (async () => { something })()

        without a ; at the end of the first line, JavaScript will try to do require(“module”)() instead

    • jwt
      link
      fedilink
      arrow-up
      1
      ·
      17 days ago

      I don’t get the semicolon either, may be a language barrier. used question marks like this for optional chaining in typescript though…