Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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