Last active
May 13, 2022 02:44
-
-
Save juunegreiros/78b886454b5a475eba68b198e6ba8af8 to your computer and use it in GitHub Desktop.
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
// valor | |
let nome = 'ju' | |
let nome2 = nome | |
nome = 'juliana' | |
console.log(nome2) | |
// ju | |
// memória | |
const pessoa = { | |
nome: 'ju' | |
} | |
const pessoa2 = pessoa | |
pessoa.nome = 'juliana' | |
console.log(pessoa2.nome) | |
// juliana |
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 ou let | |
const nome = 'juliana' | |
console.log('global:', nome) | |
if (true) { | |
console.log('bloco: ', nome) | |
// bloco: juliana | |
} | |
if (true) { | |
const nome = 'ju' | |
console.log('bloco com declaração', nome) | |
// bloco com declaração: 'ju' | |
} | |
if (true) { | |
console.log('bloco antes de declarar: ', nome) | |
// erro | |
const nome = 'ju' | |
console.log('bloco com declaração', nome) | |
// bloco com declaração: 'ju' | |
} | |
console.log('global depois do bloco:', nome) | |
// global depois do bloco: 'juliana' | |
//var | |
var nome = 'juliana' | |
console.log('global:', nome) | |
if(true) { | |
console.log('bloco: ', nome) | |
// bloco: juliana | |
} | |
if(true) { | |
console.log('bloco antes de declarar: ', nome) | |
// bloco antes de declarar: juliana | |
var nome = 'ju' | |
console.log('bloco com declaração', nome) | |
// bloco com declaração: 'ju' | |
} | |
console.log('global depois do bloco:', nome) | |
// global depois do bloco: 'ju' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment