Created
October 8, 2022 03:18
-
-
Save migtibincoski/f0ac0036d1b2a1f75db5e4580bb2b438 to your computer and use it in GitHub Desktop.
Calculations using True or False (boolean)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Confirma que "true" e "false" são do tipo boolean | |
console.log(typeof true) //Output: "boolean" | |
console.log(typeof false) //Output: "boolean" | |
//Se tentar fazer parseInt em true e false, retorna "Not a Number" (NaN) | |
console.log(parseInt(true)) //Output: NaN | |
console.log(parseInt(false)) //Output: NaN | |
//Mas nesses casos true vale como 1 e false, como 0 | |
console.log(true + 2) //Output: 3 | |
console.log(false + 2) //Output: 2 | |
//Isso não faz nenhum sentido,as acontece no JavaScript. Gente agora no Devtools do seu navegador! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment