DEV Community

Discussion on: 5 easy wins for cleaner Javascript code ๐Ÿงน

Collapse
_ezell_ profile image
Ezell Frazier • Edited on

Is it me or does the advice more-or-less pertain to modern code over 'clean' code?

Don't get me wrong or anything, I like the article and agree with it. However, I'm not going to consider a basic for-loop not 'clean'.

I guess my point is, I'm beginning to prioritize readable code over modern syntax. At my last job, ES6 was completely alien to the team. Everyone was comfortable with writing JavaScript from the mid-late 2000's, with JQuery sprinkled in.

The use-cases never called for more modern syntax.

So when I came along, I still tried my best to build with the 'lowest common denominator' in mind. Should it have to be that way? That's another conversation, but I'm not sure if I'd lump modern syntax and clean code together. The truth is always in the eye of the beholder. If a junior dev can understand what's going on, I'd consider it clean enough.

Collapse
mlevkov profile image
Mikhail Levkovsky Author

I find Javascript and Typescript really try to move towards being as succinct as possible. Sometimes it's a good thing, sometimes not.
I agree that you don't always need the fanciest bells and whistles to get the job done, however it's always nice to learn new things.
Which is why when people say they don't like Typescript because you don't get all the new ES features right away I kind of shrug, because I don't need them.
For loops are fine, I just thought it's important to demonstrate the difference between a 'for of' and a 'for in'. I think using the right type of syntax for the right job and use case is super important.