Transcript from the "const & Accessing Variables" Lesson
[00:01:02] [LAUGH] So the difference is, with const, once I have assigned a value to that variable and I have to assign a variable, I can't just declare the variable and not assign it. I have to assign it a value, and I can never change the value that that variable is assigned to.
[00:01:23] So that is the difference between let and const. And we're going to come back to that a little bit later. But just to go back to our whiteboard here, this is sort of, we could think about it as saying, what did I call that variable? Unchangeable, Variable or something like that.
[00:03:01] And we're gonna talk a little bit about the difference between let and const and changing values over time a bit later. So now how about when I use a variable? So in this case, I have a couple of phinos that are sort of like values but not exactly, which are called, one more time?
>> Expressions, excellent, yeah. So I have a couple of expressions using variables here. And essentially, what I can do now, once I have declared and assigned a value to this variable, I can use it like a value in my programs. So the same way that I could do a, Let's go back to my console.
[00:04:01] So the same way that I could do, let's say, 42 minus 10. If I create a variable called answerToLife and give it a value of 42, so declaring and assigning a variable, there's a Hitchhiker's Guide to the Galaxy reference. Now, I can use that just like I would use the literal value 42 in my code.
[00:04:54] I feel like I hear the chat nodding. [LAUGH] And similarly, that variable might be a string, right? So we can do whatever string things we usually do, right? Of like ask for the uppercase version of the string or ask the index of some character in the string. So depending on what type of value this variable remembers, we can use the variable as if it was that value in our code.
[00:05:28] Question so far, I see a couple of thinky faces. [LAUGH] So I don't know if there's thinkie emoji in the chat. Yes, question.
>> So one thing I've noticed is we don't specify any data types to these variables, it's all kinda, as you said earlier, loosey-goosey. Can you specify a data type?
[00:05:47] So where you have a variable and you only want it to be a string or you only want it to be a number, can you do that or everything is just kind of what it is?
>> Loosey-goosey, yeah, so [LAUGH] and I'm sure Mark might have more to say on this matter.
[00:06:55] The most popular of which, Mark, you wanna chime in? [LAUGH]
[00:09:20] You could have an underscore. It's not so common, though, so it's maybe less normal that you'd see one, but that's technically fine. What you cannot do is start a variable with a number or use other characters or things like emoji, unfortunate, actually doesn't know, I don't think so.
[00:10:06] There's capital letters in the middle that look like the hump of the camel's back. So I call it camelCase. And the second bullet point here with the underscores. Anybody know what that's called, as opposed to camelCase, Paul?
>> Snake case.
>> Snake case, yeah. You can also have all caps with underscores, which is screaming snake case, and yada, yada, yada.
[00:10:50] Anyway, it's not super important except to know, don't start your variables with a number. Don't put weird characters in them. When in doubt, go for camelCase. It's a cute little camel.