Skip to content

Instantly share code, notes, and snippets.

@migtibincoski
Created October 8, 2022 03:18
Show Gist options
  • Save migtibincoski/f0ac0036d1b2a1f75db5e4580bb2b438 to your computer and use it in GitHub Desktop.
Save migtibincoski/f0ac0036d1b2a1f75db5e4580bb2b438 to your computer and use it in GitHub Desktop.
Calculations using True or False (boolean)
//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