From my understanding, I believe that var a = 1; is the only truthy and the rest are falsy’s – is this correct?
No.
-
var a = 0;
Number zero is falsy. However, note that the string zero
"0"is truthy. -
var a = 10 == 5;
This is same as
var a = (10 == 5);, so this is falsy. -
var a = 1;
var a = -1;
Any non-zero number including negative numbers is truthy.
Quoting from MDN
In JavaScript, a truthy value is a value that translates to true when evaluated in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for
false,0,"",null,undefined, andNaN).
List of falsy values in JavaScript:From MDN
falsenullundefined0NaN'',"",``(Empty template string)document.all0n: BigInt-0