Created
April 4, 2014 19:43
-
-
Save marcoscastro/9981804 to your computer and use it in GitHub Desktop.
JavaScript - Exemplo do operador identidade
This file contains 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
// www.geeksbr.com | |
// Operador de identidade (igualdade estrita) | |
/* | |
Esse operador testa tanto o valor | |
quanto o tipo | |
Símbolo: === (três sinais de igual) | |
*/ | |
num = 10; | |
numStr = "10"; | |
// testando com o operador de igualdade (==) | |
// saída: True | |
if (num == numStr) { | |
console.log("True"); | |
} else { | |
console.log("False"); | |
} | |
// testando com o operador de identidade (===) | |
// saída: False | |
if (num === numStr) { | |
console.log("True"); | |
} else { | |
console.log("False"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment