

The consistent convention makes code easy to read and remember. Isn’t a good variable declaration since it starts with a capital letter. Otherwise, it gets confusing fast and other developers looking at our code can easily miss the different cases.

So we should stick with that and don’t deviate from it. Constants are upper case and functions and classes are upper camel case. Names should also have a consistent convention. This is especially important in JavaScript because the types of variables can change and there’re no type annotations to let us figure out what the type is. They shouldn’t be leaving false clues for the reader and lead them to the wrong conclusion about your identifiers.įor example, fruitArray should actually be an array rather than anything else.

So we know that the array holds Fruit objects. Instead, we should write something like: let fruits = Isn’t a good name because we don’t what list actually holds. Likewise, for arrays, we should name them with meaningful names. So we know that our variable actually holds the value of the number of apples.Īs we can see, numApples is much easier to understand than x. We should name it something like: let numApples Would be a bad variable declaration because x doesn’t reveal with it’s doing. This way, people will know what your identifier actually means.įunction, class, variables, and constants should all names that show what they’re used for. Names have to have the intention of what you’re trying to define. In this article, we’ll look at some ways to name things in an easy to understand way. To make reading and changing the code easier, the naming of them has to be good. One of the most basic parts of a program is identifiers.

Overall you will learn to write better code with improved readability.Writing clean and easily readable and maintainable code takes some effort. Unit testing is very important and you will learn to do this with Jasmine and Karma, to make handling errors easy.īy the end of the course, you will have learned to learn clean coding with functional programming, explored various modules in JavaScript, and designed patterns and principles. After that, you will master various design patterns and programming principles. You will then move on to modular JavaScript and explore the various ways you can structure your modules. Next, you will discover functional programming, how to write pure functions, and how to use built-in functional methods. You will then learn about clean code best practices while working with variables, functions objects, and the latest ES6 classes. You will be introduced to some general guidelines on how to better structure your JavaScript code. In this course, you will learn various concepts and techniques, essential principles, patterns, and practices for writing clean code in JavaScript.
