From the course: JavaScript: Best Practices for Data

Unlock the full course today

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

Create descriptive variable names

Create descriptive variable names - JavaScript Tutorial

From the course: JavaScript: Best Practices for Data

Start my 1-month free trial

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.…

Contents