Why do logical AND comparison between an empty string and false boolean returns an empty string? and why do logical AND comparison between a string and false boolean returns false?
Example:
'' && true; --> returns ''
'string' && true --> returns true;
'' && false --> returns ''
'string' && false --> returns false;
Question is why javascript behaves this way?
0
andNaN
. It's one of "falsy" values in JavaScript. So your logical AND returns those values being same asfalse
(sincetrue && false
isfalse
). developer.mozilla.org/en-US/docs/Glossary/Falsy