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

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -