+ 1

I need some clarification on this: console.log(false +7) // 7

16th Feb 2020, 7:44 PM
techsway
techsway - avatar
5 ответов
+ 7
What type of clarification? Here false mean 0. So 0 + 7 = 7
16th Feb 2020, 7:44 PM
A͢J
A͢J - avatar
+ 6
True means 1. These are boolean values. Boolean can be either true or false.
16th Feb 2020, 7:49 PM
A͢J
A͢J - avatar
+ 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"
16th Feb 2020, 8:25 PM
Seb TheS
Seb TheS - avatar
0
True means waht..?
16th Feb 2020, 7:48 PM
techsway
techsway - avatar
0
console.log(true + 7);// 8 In JS, true = 1; false = 0; That's why you got 7
16th Feb 2020, 10:57 PM
JS LOVER
JS LOVER - avatar