summaryrefslogtreecommitdiffhomepage
path: root/javascript.html.markdown
diff options
context:
space:
mode:
authorAdam <adam@adambard.com>2013-08-05 08:40:53 -0700
committerAdam <adam@adambard.com>2013-08-05 08:40:53 -0700
commit071e433dd3281c1eb25a61003782eb4ac6cbb7df (patch)
treed1503707c9cabb5eb63f749f1f0bd2620bb302a9 /javascript.html.markdown
parent54f682e5d2932121139350381cc23526b4c8002e (diff)
parent8b0cd2d599bfc1761a7341e59309c482cee535f0 (diff)
Merge branch 'master' of https://github.com/adambard/learnxinyminutes-docs
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r--javascript.html.markdown4
1 files changed, 2 insertions, 2 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 9cc7617d..cc279b9a 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -241,7 +241,7 @@ i // = 5 - not undefined as you'd expect in a block-scoped language
// This has led to a common pattern of "immediately-executing anonymous
// functions", which prevent temporary variables from leaking into the global
// scope.
-function(){
+(function(){
var temporary = 5
// We can access the global scope by assiging to the 'global object', which
// in a web browser is always 'window'. The global object may have a
@@ -249,7 +249,7 @@ function(){
window.permanent = 10
// Or, as previously mentioned, we can just leave the var keyword off.
permanent2 = 15
-}()
+})()
temporary // raises ReferenceError
permanent // = 10
permanent2 // = 15