Last active
August 29, 2015 14:20
-
-
Save pvamshi/0c65c41af0a5438c33f9 to your computer and use it in GitHub Desktop.
Scope
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
'use strict'; | |
var globalObj = "Global"; | |
/* | |
global variables are accessible to all functions | |
*/ | |
function abc(){ | |
console.log("Global object is "+globalObj); | |
} | |
abc(); | |
/* | |
Variables outside a function are also available to inner function. Vice versa is not true | |
*/ | |
function bcd(){ | |
var a = 4; | |
function inner(){ | |
var c = 7; | |
console.log("a:"+a); | |
} | |
inner(); | |
console.log("c:"+c); | |
} | |
bcd(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment