Skip to content

Instantly share code, notes, and snippets.

@pvamshi
Last active August 29, 2015 14:20
Show Gist options
  • Save pvamshi/0c65c41af0a5438c33f9 to your computer and use it in GitHub Desktop.
Save pvamshi/0c65c41af0a5438c33f9 to your computer and use it in GitHub Desktop.
Scope
'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