课程: JavaScript Essential Training
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Let
- [Instructor] The let statement defines a block-scoped local variable, meaning it's only defined within its currently-enclosed block. This allows us to safely avoid that variable scope issue we covered in the previous movie. In the exercise files for this movie, we still have the same scope problem. The right box is the same blue as the title and that's not what we want. This is the scope problem. Now I can use let to solve my scoping issue. And I do that by declaring a new variable inside the function scope using let. Save this, go back in the browser. And now we have the correct colors. Looking at this, you may be wondering, How can I do this? I'm effectively creating two variables with the same name. We have var color and then we have let color down here. The reason is we're now working inside a local scope of just this function, and inside this function, we can now declare all new variables using let and they…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
-
Variables: Containers for everything2 分钟 31 秒
-
(已锁定)
Var3 分钟 15 秒
-
(已锁定)
Scope3 分钟 37 秒
-
(已锁定)
Let4 分钟 34 秒
-
(已锁定)
Const2 分钟 58 秒
-
(已锁定)
Data types3 分钟 7 秒
-
(已锁定)
Assignment vs. comparison4 分钟 35 秒
-
(已锁定)
Math operators6 分钟 13 秒
-
(已锁定)
Challenge intro: Calculate sales tax1 分钟 35 秒
-
(已锁定)
Solution: Calculate sales tax3 分钟 30 秒
-
-
-
-
-
-