How does the below code execute?
if(a=2 && (b=8)) { console.log(a) }
OUTPUT
a=8
You're setting (not comparing) a to 2 && (b=8). Since 2 is tru-ish the second half of the expression will be executed, i.e. a = true && (b = 8), i.e. a = (b = 8), i.e. a = 8.
a
2 && (b=8)
2
a = true && (b = 8)
a = (b = 8)
a = 8