Last active
April 14, 2017 20:20
-
-
Save fititnt/9dba8e0700c13731dc54cbe99c4fcc80 to your computer and use it in GitHub Desktop.
JavaScript var VS const VS let VS (silencio)
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
<!doctype html> | |
<script src="variavel-const-let-a.js"></script> | |
<script src="variavel-const-let-b.js"></script> | |
<title>Este é um código HTML5 válido https://validator.w3.org/ (mas não é acessível)</title> | |
<!-- | |
Navegador imprime: | |
variavelConstA: ConstA | variavelLetA: LetA | |
--> |
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
<!doctype html> | |
<script src="variavel-ao-estilo-ponto-e-virgula.js"></script> | |
<script src="variavel-ao-estilo-ponto-e-virgula-funciona-aqui-tambem.js"></script> | |
<title>Este é um código HTML5 válido https://validator.w3.org/ (mas não é acessível)</title> | |
<!-- | |
Console Log: | |
123 variavel-ao-estilo-ponto-e-virgula.js:2 | |
124 variavel-ao-estilo-ponto-e-virgula-funciona-aqui-tambem.js:2 | |
Navegador: | |
123 | |
124 | |
--> |
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
document.write(variavel + "<br>"); | |
variavel = variavel + 1; | |
console.log(variavel); | |
document.write(variavel); |
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
/* | |
https://www.facebook.com/photo.php?fbid=1462524780465665&set=a.833662720018544.1073741831.100001244705769&type=3 | |
⸮ Sobre a polêmica do que usar no #JavaScript entre var, let ou const: análogo ao uso de ponto-vírgula, | |
também é possível escolher NENHUMA das três opções pra definir variáveis | |
👨👁🌎🔥 | |
*/ | |
variavel = 123; | |
console.log(variavel); | |
// fititnt@bravo:~$ cat variavel-ao-estilo-ponto-e-virgula.js | |
// variavel = 123; | |
// console.log(variavel); | |
// fititnt@bravo:~$ node variavel-ao-estilo-ponto-e-virgula.js | |
// 123 | |
// fititnt@bravo:~$ node -v | |
// v7.9.0 |
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
const variavelConstA = "ConstA"; | |
let variavelLetA = "LetA"; |
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
console.log(variavelConstA); | |
console.log(variavelLetA); | |
document.write("variavelConstA: " + variavelConstA + " | " ); | |
document.write("variavelLetA: " + variavelLetA); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment