Why I Don't Use Semicolons In JavaScript

preview_player
Показать описание
The time has finally come for me to answer the question I get asked more than any other. Why don't I use semicolons.

🌎 Find Me Here:

#Semicolon #WDS #JavaScript
Рекомендации по теме
Комментарии
Автор

i laughed so hard when i read the "What is the CSS for your hair?" XD

AugustoFnrd
Автор

Don't worry guys, the hair tutorial is at 1M 😂

karaway
Автор

I always use semicolons because I need to remember to use them in other languages.

doomer
Автор

The main reason I use semicolons is because of consistency - if there are a few instances where I have to use them, I might as well use them everywhere. Luckily, even if I forget them, Prettier inserts them for me.

magicfibre
Автор

To me a semicolon is like the full-stop of a sentence, it gives me a mental indication where an instruction ends.
So I use semicolons whenever the language kinda expects it.

djcomidi
Автор

To me, amusingly enough, the whole video is actually a list of reasons to use semicolons. Not using them is relying on prettier and the JS compiler to be smart enough to infer proper semi colon insertion. Semicolon vs no semicolon is kind of like === vs ==. Why do I use semicolons? the same reason I use ===. so that I am not relying on the compiler or a formatter to infer my intent, but rather to be explicit myself.

ng
Автор

JavaScript, with its C-like syntax, looks kinda cursed without semicolons at the end of lines tbh. Besides, if you use other C-like languages, you'll have muscle memory to basically just put it there before hitting enter.

chlorobyte_projects
Автор

I use full colons. I don't half-a$$ my line endings :)

alanthomasgramont
Автор

Hair tutorial:
1. be born with good hair genes
2. go over your hair once with a comb

jamesevans
Автор

Kyle's next video : Why i don't use JavaScript in JavaScript

loogie
Автор

I don't understand the "do whatever you're used to" argument. The two languages I use most are C++ and Python. One requires semicolons, one requires none. It's really not that hard to switch.

cool_scatter
Автор

On every other line I add a long string of all semicolons. I just like it that way

whatthefunction
Автор

While I am firmly in the "use semicolons" camp, that fact that you don't use them hasn't stopped me from learning things from your code / language tutorials.

johnvandencruyce
Автор

5:31 - That's the great thing about using these automatic formatting tools, cuz you can write your code exactly like you want and as soon as you hit "save", IT'S GOING TO FUCK UP YOUR HAND CRAFTED PIECE OF ART :D

TanelM
Автор

Its a social contract, it provides you with a knowledge of intent. When you write a line with a semi colon, you know that when that semi colon comes, this is a full line. So when you write your code on a fancy 4k monitor and you can watch over the code like a hawk, just remember the next guy reading your code could be in nano on a linux terminal limited to a 14" CRT monitor and a max line char count of 80 in a dim lit basement trying to figure what the code which kills production is about.

Its like a lock, a social contract, the locks we encounter are petty and forced open quite easily, but it conveys a meaning. You didnt install the lock because you know it would protect your stuff or think that everyone is a criminal, no you installed it to convey a message, you want to protect the thing behind the lock, but 99% of the case it prevents by merely being present. Just like your semi-colon prevents 99% of mixing the line with another line.

runejensen
Автор

If you need extensions to avoid bugs when not using semicolons, it's obviously not a good practice

DimageSapelkin
Автор

"No no no, not that question!" 😂😂😂

nsharma
Автор

Referring to ASI section of ES documentation confirms the following.

Most ECMAScript statements and declarations must be terminated with a semicolon. Such semicolons may always appear explicitly in the source text. For convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are described by saying that semicolons are automatically inserted into the source code token stream in those situations.

In your case, ES6 is being used through babel. It's a transpiler and it may add the missed semicolons in the process of transpiling the source text to native JS.

IMO, good practice is to enable ES linter and it can help to avoid most of the silly mistakes that can culminate the application in undefined state at later point in the time line.

aledc
Автор

Hey Kyle. Been watching your videos for a couple of months and love the content. Personally, I got started programming in Java, C#, C++ so I will forever put semicolons at the end of every statement, even if they aren't required. On top of that, I don't even think about putting a semicolon anymore. It just appears because of muscle memory. Additionally, for me, its just so much more clear when reading code. Glad you have a method that works for you. Keep the content coming!

petercopus
Автор

Appreciate the content & 100% agree with your message about consistency. I have to admit though, that as I guy who started programming with Javascript 1.0 back in the Netscape 2 days, I always thought semicolons were required. Whether they were ALWAYS optional is unclear to Google at this point and I certainly can't remember my code from those days, but nevertheless, I can appreciate your reasoning, especially if you're constantly bouncing back & forth between languages that don't leverage them.

MercuryNewt