今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Explore block-scoped variables with code
- [Instructor] All right so let's explore the block scope variables a little bit further in this video. So let's remove all this code and let's start from scratch. The first thing I'm gonna do is declare a let variable, so let's do a warrior one and let's assign again the ninja and let's do a const right after that and let's do a warrior two. Let's call this guy viking. So if I console log these two right now and because they are in my scope I shouldn't have any issues, so let's start with that. So let's save, let's go back here, and we have ninja and viking, so we're good. Then if we want, and I'm going to be proactive and this will return an error. If we were to reassign a warrior two, so let's do warrior two and reassign it to, let's say samurai, and then console log warrior two we'll have an issue, because this is a variable that can not be mutated. So let's go here and we got assignment to constant…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。