课程: JavaScript: Best Practices for Data
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Remove unused variables
- [Instructor] I have code with some variables, a few functions, and some placeholder console.log statements for output. After some iteration my needs have changed, and I no longer need to run analysis using the cdRatio or efRatio. So I can take out the second and third functions, and I can take out the second and third console.log statements. At this point, I've cut a lot of my code. And especially if I was working in a big codebase, it can be easy to overlook orphaned variables, that is, variables that are declared but no longer used. ESLint can help me watch for this with the no-unused-vars rule. If I prune or restructure my code, such that a variable is no longer used anywhere in my code, ESLint will catch that for me. In my eslintrc file I'll add a new rule, no-unused-vars, and a simple string for the value of error. Now switching back to app.js, I have errors on line four and five that reference unused…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
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 秒
-
-
-
-
-