今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
What is scope in JavaScript?
- [Instructor] For some, JavaScript's code can be a bit intimidating but it's very simple. Put in its simplest terms, scope determines accessibility or visibility of the variable. Depending where and what type of scope we are using it will determine if your variable is available when you call it. Let's type some code to visualize what scope is. Let's remove the console log here and let's add a warrior, so var warrior = Ninja. Then let's create a function. We'll create a function with a const this time, and we'll call this one screamWarrior and we won't take any parameters. Inside of that function, we'll define another variable, warrior2 = Samurai. Then inside of the function, we'll console.log warrior and warrior2 and outside of the function definition we'll run the function and then we'll console.log the warrior1 or the warrior and warrior2 and you can save this. When you look into this code here, you have the warrior…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。