when if statement become AND operator

es404020 - Dec 10 '21 - - Dev Community

I was going through a tutorial recently and I found out this developer kept using && operator to perform if statement. Take a look.

const status  = true

function logSomething(){

console.log('hello world');

}

=========if way========================


if(status) logSomething();

===================and way ======================

status && logSomething();

Enter fullscreen mode Exit fullscreen mode

They do the same thing .Thanks for reading

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player