Skip to content

Instantly share code, notes, and snippets.

@AugustoPedraza
Created March 4, 2013 16:32
Show Gist options
  • Select an option

  • Save AugustoPedraza/5083521 to your computer and use it in GitHub Desktop.

Select an option

Save AugustoPedraza/5083521 to your computer and use it in GitHub Desktop.
Example scope...
function logValues(head, four, five, six){
console.log(head);
console.log("four = " + four);
console.log("five = " + five);
console.log("six = " + six );
console.log("\n");
}
var integers = function( ){
var four = 4;
var five = 5;
var binaries = function( ){
var five = 101;
var six = 110;
//#2 At this point, four is 4, five is 101 and six is 110.
logValues("#2", four, five, six);
four += five + six;
//#3 At this point, four is 215, five is 101 and six is 110.
logValues("#3", four, five, six);
};
//#1 At this point, four is 4, five is 5 and six is not defined.
logValues("#1", four, five, (typeof six === 'undefined' ? 'undefined' : six));
binaries( );
//#4 At this point, four is 215, five is 5.
logValues("#4", four, five, (typeof six === 'undefined' ? 'undefined' : six));
};
integers( );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment