From the course: JavaScript: Best Practices for Data

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Use individual statements to create variables

Use individual statements to create variables - JavaScript Tutorial

From the course: JavaScript: Best Practices for Data

Start my 1-month free trial

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…

Contents