0

intricate

If the Boolean value is assigned to an integer, then the truth becomes 1, and the false becomes 0. If an integer value is assigned to a Boolean, then 0 becomes false (false) and any value not equal to zero becomes true. please show these variations with an example

6th Jun 2019, 6:10 PM
Š°Ń€Ń‚ŠµŠ¼ Š³ŠøŠ¼Š°Š“ŠµŠµŠ²
Š°Ń€Ń‚ŠµŠ¼ Š³ŠøŠ¼Š°Š“ŠµŠµŠ² - avatar
1 Answer
+ 1
+ sign: convert boolean (or any other data type) to integer (equals to Number()) !!: converts any data type to boolean (equals to Boolean()) a = true; b = false; alert(+a) //1 alert(+b) //0 alert(+a + +b) //1 + 0 = 1 x = 5; y = 0; alert(!!x) //true alert(!!y) //false alert(+!!x) //1 alert(+!!y) //0
6th Jun 2019, 6:32 PM
Airree
Airree - avatar