DEV Community

Discussion on: Some Best Practices of Javascript for clean and better code quality...

Collapse
 
valeriavg profile image
Valeria

Some of these can be dangerous practices.

Chaining too much array methods, for instance, will make it significantly harder to debug if any problem appears, not to mention all the extra allocations.

You shouldn't have to fetch several requests at the same time, it slows them down and creates extra load on the server. Promise.all and similar are a workaround for the cases when you don't have any control over the server but still need to make sure that all data is delivered.

There's nothing wrong with using switch or chaining promises, or using a for loop instead of a functional style and mutating the array directly when that makes sense.

JavaScript is one of the most versatile languages and the only best practice is has is:

Keep things as simple as possible to not shoot yourself in the feet