logic - Why does 2 && 3 results in 3 (javascript)? -
this question has answer here:
when type in browser's console:
console.log(2 && 3)
it results second number (in case 3):
3
can explain me why?
if left hand side of &&
evaluates false value, whole expression evaluates left hand side.
otherwise evaluates right hand side.
2
true value, 2 && 3
3
.
for comparison, try console.log(0 && 1)
, console.log(false && "something")
.
Comments
Post a Comment