课程: JavaScript Essential Training
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Scope
- [Narrator] In the MDN web docs, VAR is defined as a globally scoped variable. That means if you first assign a value to have VAR, and then inside a function, assign it a new value, that new value inside the function takes effect in all corresponding code. Even outside the function. This can cause what's known as scope issues, which result in unintended behavior errors, and a lot of frustration, as we try to figure out, why things aren't working properly. Let me show you a practical example of how this works. In the exercise files, I've set up these two boxes, ah, the color and the text in here, is populated using JavaScript. Looking at the script, it's straightforward, We set up a VAR, with the name color, and then we populated with a color in this click case, purple. This is a CSS color, which is why it works. You can also put in a hex value, if you want it to here, and it'll work the same way. Then…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
-
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 秒
-
-
-
-
-
-