This course has been updated! We now recommend you take the Deep JavaScript Foundations, v3 course.
Transcript from the "Partner Up for Scope Q&A" Lesson
[00:00:00]
>> Kyle Simpson: What questions came up as a result of going through it with your neighbor, anything?
>> Speaker 2: So we were having a back and forth on line eight and nine about whether foo got dealt with at compile time or was left to the second phase.
>> Kyle Simpson: Okay, which, the foo on line eight is the question?
[00:00:18]
>> Speaker 2: Yes.
>> Kyle Simpson: Okay, so the foo on line eight does get dealt with at compile time from the perspective of needing to store that metadata, that it is in the LHS position. But foo on line 8 is not creating a variable entry, it's not making a marble and putting it in a bucket, that happened on line 7.
[00:00:36]
>> Speaker 2: Okay.
>> Kyle Simpson: So it's kinda both.
>> Kyle Simpson: What else?
>> Speaker 2: Is there a good way of accessing that line one from line four and a half?
>> Kyle Simpson: No, the only way to access it is for a global variable you can use the cheat that global variables are properties of the global object.
[00:01:00] Which is generally frowned upon, but if you really needed to you could do that.
>> Speaker 2: So what's the best practice if that's the case?
>> Kyle Simpson: Well the best practice is, don't shadow if you're gonna need access to it.
>> Speaker 2: I'm sorry, what was the question?
>> Kyle Simpson: The question is, on line four and a half is there any way to access the foo from line one?
[00:01:17]
>> Speaker 2: The foo from line one, and then line four, are those the same marble? Or are they given marbles in different scopes, right, yeah.
>> Kyle Simpson: The foo from line 1 is a red marble in the red bucket, the foo from line 4 is a blue marble in the blue bucket.
[00:01:36]
>> Kyle Simpson: That's why we call that shadowing.