课程: JavaScript: Scope

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Define let/const variables

Solution: Define let/const variables - JavaScript教程

课程: JavaScript: Scope

Solution: Define let/const variables

- [Instructor] Hopefully you didn't have any troubles doing the challenge and the goal was to make you practice using block scope variables and having them in different situations, where they are accessible internally to a block of code. If you've accomplished this, that's awesome. Okay, now so let's look at what I did on my side. So what I did first is to declare an array of warriors and they are globally block scope available. So right now we could use within the block of the entire file, this array. And then I created a function here which is also globally available, so again, they are accessible within the file because they are in the block scope here. Then I made sure through a console log that I had access to the warriors. So kinda doing the accessibility validation inside of my function. So I'm pretty sure that if I run this I'm gonna see the array but we'll check the browser in a few seconds. So I use the…

内容