课程: JavaScript: Best Practices for Data

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Use individual statements to create variables

Use individual statements to create variables - JavaScript教程

课程: JavaScript: Best Practices for Data

Use individual statements to create variables

- [Instructor] JavaScript allows the declaration of multiple variables using a single keyword, like in my code here. It can make code more concise, but it has some drawbacks. One issue is that it's a little too easy to put in a semicolon instead of a comma, or vice versa, and that kind of error is subtle and can be difficult to identify. Also, when you're using a debugging tool, you can step through separate statements individually, rather than all at once when they're declared like this. So I prefer to use separate statements when I create variables. ESLint has a rule for this, which is one bar. This rule supports a lot of configuration options for different keywords. But I want to do a more broad-based rule. I need to specify an issue level and a rule as an array. So that's one dash var colon, and then my array with an issue level of error, and a rule of never. So I'll save that, and over in my app.js file, I have…

内容