More than a decade ago, JavaScript was just a tool to make websites interactive and better-looking but things have changed considerably ever since.

Now JavaScript is widely used in every sphere of production, ranging from web development to games to mobile applications. Moreover, for any given task chances are you will find a stable and fully-fledged JavaScript.

It is thus becoming increasingly important to stay up-to-date with all the best practices to give you and your code an edge over others, especially in job interviews and technical rounds.

Below are 5 modern rules of JavaScript that every developer should know to write clean code and become proficient:

1. Destructuring

Often times we have many values and properties relating to the same thing and we store and pass these values and data using objects.

The standard way to access the values is given below:

const mobile= {
    id: 42,
    brand: 'Apple'
};
console.log(mobile.id);
console.log(mobile.brand);

While this approach works, you can see code repetition here as we keep referencing the object each time to get value. There is a better way to deal with this.

const mobile= {
    id: 42,
    brand: 'Apple'
};
var {id,brand} = mobile;
console.log(id);
console.log(brand);
//Destructuring can be applied to functions as well
var myFunction= ({id})=>{           
   console.log(id); 
 }
myFunction(mobile);

#javascript #programming #coding #web-development #technology

5 Modern Practices of JavaScript that Every Developer Should Know
1.50 GEEK