What is "x && foo()"?

Viewed 4158

I saw somewhere else said,

x && foo();

 is equal to

if(x){
    foo();
}

I tested it and they really did the same thing.
But why? What exactly is x && foo()?

5 Answers
Related