Created
March 26, 2017 02:49
-
-
Save cristofersousa/ead609f03c55f50b64969aedf1ce1999 to your computer and use it in GitHub Desktop.
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
scope = "global"; // declara uma variável global mesmo sem var | |
function checkscope2() { | |
scope = "local"; // alterando o valor da variável global pela local | |
myScope = "local"; // adicionando uma nova variável global mesmo dentro da função | |
return [scope, myScope]; // retornando os dois valores declarados dentro da function | |
} | |
checkscope2(); // ["local", "local"]: temos efeitos colaterais aqui, esperavamos **["global, local"]** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment