Created
March 4, 2013 16:32
-
-
Save AugustoPedraza/5083521 to your computer and use it in GitHub Desktop.
Example scope...
This file contains hidden or 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
| 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