Created
July 17, 2012 17:30
-
-
Save renatoargh/3130709 to your computer and use it in GitHub Desktop.
Closures
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
function escopo(parametro){ | |
var auxiliar = parametro + 2; | |
function interna1(){ | |
console.log("auxiliar: %s - parâmetro: %s", auxiliar, parametro); | |
//Acesso a atributos internos de escopo() | |
} | |
function interna2(){ | |
console.log("Invocando a função 'interna1'..."); | |
interna1(); | |
//Acesso a funções internas de escopo() | |
} | |
interna2(); | |
//A função interna 1 e 2 enxergam os atributos internos de "escopo()" | |
} | |
escopo(1); | |
//Este código loga: | |
// Invocando a função 'interna1'... | |
// auxiliar: 3 - parâmetro: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment