DEV Community

Tips and Tricks for Better JavaScript Conditionals and Match Criteria

Milos Protic on June 25, 2019

Originally posted on devinduct.com Introduction If you enjoy seeing the clean code, like me, you will try to write yours with as litt...
Collapse
 
ianspiderhan profile image
Ian Han

Excellent article thankyou.

I came to your one from a very odd route. I was reading an article on my phone which I lost then looked for it again and found your article.

The article I originally was reading was this dev.to/hellomeghna/tips-to-write-b...

To me, and I maybe wrong, just looks like the second author has just reworded your article.

Collapse
 
proticm profile image
Milos Protic

Thank you, I appreciate it!

Hmm, it seems you're right :) It does look very similar, not to say contextually the same :)

Collapse
 
karataev profile image
Eugene Karataev

Nice tips!
It should be kept in mind that some features from ES2015+ are not transpiled by Babel. Array.prototype.includes and Map should be explicitly polyfilled if it's necessary to support older browsers (IE, for example).

Collapse
 
proticm profile image
Milos Protic

Thanks!

Yes, I agree. But also, we should slowly stop caring about the IE and it needs. If we do that, we have solid cross-browser support.

Collapse
 
rafalmiler77 profile image
rafalmiler77

car?.model doesn't look like vanilla JavaScript.

Collapse
 
proticm profile image
Milos Protic • Edited

It's the official proposal. You can check it out here.

Today, you can use it with Babel, but hopefully, it will be fully supported one day.

I guess you didn't fully read section 7 :)

Collapse
 
chencong6837 profile image
码飞_CC

you are not writing the code just for the machine, you are writing it for the "future self" and for the "other guy".
I can't agree anymore