课程: JavaScript: Best Practices for Data
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Create descriptive variable names - JavaScript教程
课程: JavaScript: Best Practices for Data
Create descriptive variable names
- [Instructor] Brevity may be the soul of wit. But as my variable names here illustrate, writing code requires striking just the right balance between brevity and clarity. I have four variables here named A, B, X and Y. Looking at the first two, which are arrays, I can make a guess about what each contains, but I can't be sure. Inventory in a store's produce section, a couple shopping lists, ingredients for recipes. The final two are pretty much a complete mystery. Just numbers with no context. Now, when a parser is processing my JavaScript statements, it doesn't care about variable names at all. But for me and other humans working with the code, it's really helpful to understand what a variable is meant to contain. This lets me verify that the data matches the intent and also helps me understand the flow of my program as the variable's referenced in other statements. My first two variables are intended simply as lists.…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
Prefer const, then let5 分钟 7 秒
-
(已锁定)
Use individual statements to create variables1 分钟 41 秒
-
(已锁定)
Create descriptive variable names3 分钟
-
(已锁定)
Standardize acronym case2 分钟 22 秒
-
(已锁定)
Remove unused variables1 分钟 18 秒
-
(已锁定)
Challenge: Declare variables45 秒
-
(已锁定)
Solution: Declare variables5 分钟 38 秒
-
-
-
-
-