0
is falsy, so the other expression in the logical ||
will be evaluated. That is why you are getting "0"
. You can confirm that like this
1 || console.log("First");
0 || console.log("Second");
# Second
Since 1
is truthy, it short circuits and doesn't execute the console.log("First")
, but 0
is falsy so it goes ahead and executes console.log("Second")