Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JavaScript Scoping Var Global
var globalVariable;
globalVariable = 'I Love Pizza!';
function iChangeTheVariable() {
globalVariable = [59, 600, 843];
}
iChangeTheVariable();
console.log(globalVariable); // Will be [59, 600, 843]
var globalVariable;
globalVariable = 'I Love Pizza!';
console.log(globalVariable); // Will be 'I Love Pizza!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.