Make Your If Condition More Beautiful In JavaScript

Hello devs,

In this JavaScript tips tutorial, I will show you, how we can beauty our if condition or conditional statement in JavaScript. It is not a widely used coding pattern. But you can use this in your code. 

So you can take it as to improve your js skills with these tips. So let's take an example to see the code:

If we have to execute a function just if a condition is true, like below:

if(condition){
    toto()
}

 

But we can use a short-circuit just like 👇

condition && toto()

 

Hope it can help you.

 

#javascript