Transcript from the "Thread of Execution" Lesson
[00:01:10] And so, here we go, who is gonna have the honor of doing line one? Was it Kyla? Kayla, line one, what are we doing with our code here? Verbalize it for me, Kyla.
>> off screen female: You're defining a constant called num.
>> Will Sentance: Beautiful, and?
>> off screen female: Three.
>> Will Sentance: And assigning it the value three.
[00:01:27] There it is, people, that means, from now on if we see num in our code, we know that it’s gonna go look and find the value, what Kayla?
>> off screen female: 3.
>> Will Sentance: 3, she’s spot on. Excellent to Kayla for being the first person to be called upon. Next line, now I turn to Matt.
>> off screen male: We’re defining the function multiply by two.
>> Will Sentance: Thank you Matt, exactly. And this is to say, people, when we define a function, there's two parts. There's our identifier, that is the fancy word for the label for anything you're storing in computer's memory. The identifier here is multiplied by two, the identifier before was num.
[00:02:06] I recently learned this word, the identifier, and we then take all the code of the function. We're not gonna run any of it right now. We're gonna take it, bundle it up, and store it in the computer's memory, like a string of characters, all the code of that function.
[00:02:40] Now weaves down to where, Braden. What does it hit next?
>> off screen male: It defines the variable output.
>> Will Sentance: Yeah, I'm gonna call it constant, people tend to seem to be using variable as a generic term for label plus data, identifier plus data. But think about it, it literally means, I can vary the data that I store in that label.
[00:03:04] And with a constant I can't vary, I can't take away what I had stored there before and store something else there. We'll see more about that later on. So let's say we declare a constant output, excellent. Now Braden, what am I gonna store in output? Do I know yet?
>> off screen male: No.
>> Will Sentance: I don't, exactly, because this right hand side is what, Braden?
>> off screen male: It's to your function.
>> Will Sentance: It's-
>> off screen male: A function call.
>> Will Sentance: Function call, excellent from Dan. Excellent from Dan. A call to a function, it's a command. I can only store values, that's fixed, final things.
[00:03:38] I can't store a go do some work. Dan, what tells me this right hand side is a command?
>> off screen male: The parenthesis.
>> Will Sentance: Parenthesis, exactly, exactly, right. So for now, it's gonna remain uninitialized. This is in contrast to the old days where it's undefined. Because again, if you're declaring a constant output, if we saved the literal data undefined here, well then we wouldn't be able to change it out for the value that comes back from the function.
[00:04:04] So now we just say it's not really even fully stored yet. I'm gonna show it here, but it's not got any value in it yet. Okay, so we wouldn't even, if we were to inside the running and multiply by two try and log output, we wouldn't see undefined, we'd just see it's not there.
>> off screen female: Three.
>> Will Sentance: Three, well done.