JavaScript's Lax Attitude Towards Semicolons
Description
A two-panel meme contrasting how different programming languages handle semicolons. The top text reads, "When you feel like using semicolons only occasionally". The left panel, labeled "Literally any programming language", features a still of Willem Dafoe as Norman Osborn from the movie Spider-Man, looking distressed and saying, "YOU CAN'T DO THIS TO ME". This represents programming languages with strict syntax rules where semicolons are mandatory. The right panel, labeled "Javascript", shows Ken Jeong as Señor Chang from the TV show Community, wearing a sombrero, leaning back relaxedly in a chair with his feet up, and saying, "I'll allow it.". This humorously depicts JavaScript's feature of Automatic Semicolon Insertion (ASI), which makes the use of semicolons optional in many contexts. For senior developers, the joke hits on the long-standing debate about JS's quirks, where this flexibility can be both a convenience and a source of subtle, hard-to-diagnose bugs if not fully understood
Comments
22Comment deleted
JavaScript's ASI is like a pull request approval from a junior dev at 5 PM on a Friday. It seems helpful at the time, but you just know you'll be debugging a cryptic 'undefined is not a function' error over the weekend
JavaScript’s fine with you skipping semicolons - until ASI turns ‘return\n{ ok: true }’ into ‘return;’, and suddenly the post-mortem is about your “relaxed coding culture.”
After 15 years of arguing about semicolons in JavaScript, we've finally reached consensus: the real bug was the friendships we destroyed during code reviews over whether to use them or not
JavaScript's ASI is the programming equivalent of 'move fast and break things' - except it's your parser that's moving fast, and your code that's breaking in production when you accidentally return undefined because the semicolon insertion decided your return statement was complete on its own line. Meanwhile, every other language is sitting there like a strict parent insisting you finish your statements properly, while JavaScript is the cool uncle who lets you get away with anything until suddenly you can't figure out why `return\n{value: true}` doesn't work
JavaScript lets you treat semicolons as a lifestyle choice - right up until an IIFE or a return newline turns ASI into your on-call rotation
JavaScript: "I'll allow it" - right up until ASI turns return\n{} into return; {} and your concatenated bundle ships a heisenbug that only reproduces without a newline at EOF
JS ASI: optional semicolons for that artisanal 'undefined in prod' flavor every senior dev secretly loves debugging
cough cough python Comment deleted
пояснительная бригада Comment deleted
В джс иногда можно без семиколон Comment deleted
Python: "Да кто такие эти ваши семиколонс нахуй?" Comment deleted
Да ладно даже в Rust можно без разок в конце блока) Comment deleted
В расте это обусловлено семантически, в жабаскрипт семиколоны практически декоративные Comment deleted
There are few cases when they’re required Comment deleted
O da vi iz Anglii Comment deleted
*Laughs in Kotlin* Comment deleted
*Laughs in Scala* Comment deleted
*laughs in JavaScript* Comment deleted
*laughs in swift* Comment deleted
lol Comment deleted
golang, ruby ? Comment deleted
Kotlin Comment deleted