Skip to content

Instantly share code, notes, and snippets.

@danomanion
Created November 29, 2019 12:41
Show Gist options
  • Save danomanion/2609eb0abc09090f4e471c9c3593b6b0 to your computer and use it in GitHub Desktop.
Save danomanion/2609eb0abc09090f4e471c9c3593b6b0 to your computer and use it in GitHub Desktop.
Analyzing Function Scope Review
let val = 30;
console.log(`Global: ${val}`);
function myFunc(val) {
val = val * val
console.log(`Function: ${val}`);
}
myFunc(val)
setTimeout(function() {
console.log(`Global Afterwards: ${val}`)
}, 2000)
// ---
let myOrangeObject = { type: 'blood', numOfWedges: 12, sweetness: 'mid-level' }
console.log(myOrangeObject.type)
function changeOrange(obj) {
obj.type = "Clementine"
}
changeOrange(myOrangeObject)
setTimeout(function() {
console.log(`Afterwards: ${myOrangeObject.type}`)
}, 2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment