Mini Quiz: Javascript Scoping
Sheldon Nunes
Posted on October 8, 2018
A quick quiz question on javascript scoping. Try and figure this out before executing in browser
If you were to create this object:
var person = {
name: 'Dave',
weight: 100,
height: 180,
calculateBMI: function() {
console.log(this);
function innerFunction() {
console.log(this);
}
innerFunction();
}
}
When running person.calculateBMI()
what object will this
be mapped to when logged by the innerFunction?
💖 💪 🙅 🚩
Sheldon Nunes
Posted on October 8, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.