Check out a free preview of the full Introduction to JavaScript course:
The "Semicolons and Q&A" Lesson is part of the full, Introduction to JavaScript course featured in this preview video. Here's what you'd learn in this lesson's course:

Brian discusses the usage of semicolons and the choice of 'var' versus 'const' and 'let' in JavaScript code.

Get Unlimited Access Now

Transcript from the "Semicolons and Q&A" Lesson

[00:00:00]
>> Brian Holt: Semicolons, you've probably noticed these. This is like a period in JavaScript language, right? It's the end of a sentence. It's the end of a thought. Or, as it's called in JavaScript, it's the end of a statement, right? Technically, they are optional. So if I went through and deleted all of these, this still executes because there's a thing called auto semicolon insertion, ASI.

[00:00:29]
There's some people that prefer writing code this way. There are other people that don't like writing code this way. I'm just showing you so you know that it is technically valid. And I don't care [LAUGH]. I really don't. Now I just have a tool that inserts it for me automatically.

[00:00:45]
And I never have to think about it ever again. But that's up to you how you wanna do it. Technically, at the end of a day, JavaScript is inserting these semicolons there for you. So they end up there whether or not you write them there.
>> Brian Holt: But that's what it's for.

[00:00:59]
It's for ending a sentence or ending a statement.
>> Brian Holt: Okay.
>> Brian Holt: Just so you know, I have yeah, go ahead.
>> Speaker 2: Can we use var to declare a variable?.
>> Brian Holt: So there is an old way of doing it. That's a good question. Can we use a var? So there is a var like this.

[00:01:23]
This is the old way of doing it.
>> Brian Holt: There are people that would disagree with me, but I would say never use var ever, cuz there's no reason to. I think constant let totally eclipsed the need for var. It has some different semantics, but you can logically think that it works like let, right?

[00:01:40]
So notice, this still works with var, I was able to reassign it here. I choose not to use var. Kyle Simpson would fight me on it and he would be wrong, yeah.
>> Speaker 3: I notice so far you're only using integers, will let and constant still allow you to go into decimal places?

[00:01:56]
>> Brian Holt: Yes, so you can see here, I can change that to be.
>> Brian Holt: Yeah, suffice it to say, you can. So in JavaScript. Here we go, and notice that that has decimals. In JavaScript, there is no difference between integers and decimal places or floats, as they're often called in computer sciencey stupid terms.

[00:02:25]
There's no difference between them. There's just one number type. And we'll get into other things like strings here in a second. But does that answer your question? Cool.