Created
April 10, 2016 14:05
-
-
Save andrewjmead/432e9c6c5e973be502488d6ad6f85403 to your computer and use it in GitHub Desktop.
Auchomag - Variables
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
// EXAMPLE ONE | |
var foo = 'Andrew'; | |
console.log(foo); // 'Andrew' | |
function foo () { | |
return 'From foo function' | |
} | |
console.log(foo()); // 'From foo function' | |
// At this point we have no way to access the foo variable 'Andrew' | |
// EXAMPLE TWO | |
var bar = 'Mike'; | |
var obj = { | |
bar: function () { | |
return 'From bar function' | |
} | |
}; | |
// Here we have access to both bar and obj.bar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for taking the time to do this, I see what you mean, even though I don't understand the reason why. It has helped.