From the course: JavaScript: Best Practices for Data
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Quote object property names consistently - JavaScript Tutorial
From the course: JavaScript: Best Practices for Data
Quote object property names consistently
- [Instructor] My sessions object contains session labels and names for the first few sessions at a conference. The first key, plenary, is a single word and doesn't strictly need quoting in JavaScript, but the other two use hyphens in their names, which aren't valid property names unless you pass them as strings, so they're quoted here. I prefer to use quotes around property names only where needed. The lack of quotes around the key that doesn't need them actually provides a bit of a performance edge in the parser, and it does keep the code less cluttered, especially when most keys don't need the quotes. ESLint supports LinkedIn property names style with the quote-props rule, to support quotes only where needed, you use the as-needed value. So I'll update my ESLint RC file with quote props, and an array value with error and as dash needed. And I'll save that, and then back in my JavaScript file, that first one's flagged…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.