Created
April 24, 2017 04:58
-
-
Save fxcosta/c184d118c702207061bb28361bda3e76 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
let color = "purple"; // escopo global. todo mundo tem acesso a ela | |
function belt () { | |
let color = "blue"; // redefinimos o valor de color somente dentro desse escopo | |
function myBelt () { | |
let color = "brown"; // redefinimos mais uma vez o valor de color para ser usado somente nesse escopo | |
console.log(color); // brown | |
} | |
myBelt(); // chamará a função myBelt que imprimirá brown | |
console.log(color); // blue | |
} | |
belt(); // chamará a função belt que tem seu escopo próprio | |
console.log(color); // purple, porque é o valor global |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment