5 simple changes that will make you a better JavaScript developer
Introduction
One of the beautiful things about programming is that there are hundreds of different roads to the same destination. Everyone has their own style and everyone has their own preferences. Whatever your style or preference though, there are some simple techniques you can adopt to make your life, and the life collaborators (including your future self) easier.
Use descriptive names
Using descriptive names is one of the most straight forward changes you can make to your workflow. By using descriptive names for functions and variables, your code can become almost entirely self documenting, although I would still suggest adding comments to complex functionality. We’ve all been there, you open an old project or a project you’ve inherited from another developer and it’s full of generic names which mean nothing. Take the following example, the code is fetching some items
from which it's creating a new Array, Alt items
, before setting the icon
property to 'star'. In this instance you as the developer, have no idea what those items
that are being fetched and manipulated are:
let items = fetchItems()
let altItems = items.filter(item => item.featured == true)altItems.forEach(item => {
item.icon = 'star'
})