0

The following example returns 0:

console.log(0 && 0 === 0);

The following example returns true:

console.log(2 && 2 === 2);
Alexis_Ni
  • 907
  • 7
  • 14
  • 1
    Did you mean to run `(0 && 0) === 0` instead? That `2 && true` returns `true` is expected, as is the result of `0 && true`. – Bergi Dec 30 '19 at 14:36
  • 2
    `A && B` returns the value `A` if `A` can be coerced into false; otherwise, it returns `B` (taken from https://mariusschulz.com/blog/the-and-and-or-operators-in-javascript ). `0` can be coerced to `false`, so you are getting back the value of A which is `0`. – WGriffing Dec 30 '19 at 14:42

0 Answers0