Commit 9914d384 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

Scoping

parent 77f015ee
/////////////////////////////////////
// Lecture: Hoisting
/*
calculateAge(1988);
function calculateAge(year){
......@@ -9,5 +12,39 @@ var calculateAge2 = function(year){
calculateAge2(1988)
console.log(x);
var x=23
*/
/////////////////////////////////////
// Lecture: Scoping
// First scoping example
var a = 'Hello!';
first();
function first() {
var b = 'Hi!';
second();
function second() {
var c = 'Hey!';
console.log(a + b + c);
}
}
// Example to show the differece between execution stack and scope chain
var a = 'Hello!';
first();
function first() {
var b = 'Hi!';
second();
function second() {
var c = 'Hey!';
third()
}
}
function third() {
var d = 'John';
//console.log(c);
console.log(a+d);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment