• Eranziel@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    3 months 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
      3 months 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