+ 1
I need some clarification on this: console.log(false +7) // 7
5 Respostas
+ 7
What type of clarification?
Here false mean 0. So 0 + 7 = 7
+ 6
True means 1.
These are boolean values. Boolean can be either true or false.
+ 1
True could refer to "something happened 1 time", while false could refer to "something happened 0 times"
Examples:
5 == 9 ---> "5 equals 9" ---> false ---> "5 equals 9 happened 0 times"
3 > 2 ---> "3 is greater than 2" ---> true "3 is greater than 2 happened 1 time"
0
True means waht..?
0
console.log(true + 7);// 8
In JS, true = 1;
false = 0;
That's why you got 7