In Javascript the binary logical operators '&&' and '||' behave differently compared to the same operators in a programming language like Java.
This is because javascript binary logical operators can return even a number or a string, not just true or false!
And again this is possible because Javascript has this concept of 'Truthy' and 'Falsy'.
Anything of the below is considered as false by javascript:
''
false
NaN
null
undefined
Everything else is considered as true
Here is a short post on how the above concept affects the binary logical operators in javascript:
Top comments (0)