Created
October 29, 2013 13:41
-
-
Save Chavao/7214837 to your computer and use it in GitHub Desktop.
Escopos em JavaScript
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
var valor = "Valor Global"; | |
var foo = (function() { | |
var valor = "Var de Foo"; | |
var funcao = function() { | |
alert(valor); | |
} | |
return { | |
funcao: funcao | |
} | |
})(); | |
var bar = function() { | |
valor = "Valor de Bar"; | |
alert(valor); | |
} | |
var baz = function() { | |
var valor = "Valor de Baz"; | |
alert(valor); | |
} | |
alert(valor); | |
bar(); | |
baz(); | |
foo.funcao(); | |
alert(valor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment