Mini Quiz: Javascript Scoping

sheldonnunes

Sheldon Nunes

Posted on October 8, 2018

Mini Quiz: Javascript Scoping

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?

💖 💪 🙅 🚩
sheldonnunes
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.

Related

Mini Quiz: Javascript Scoping
challenge Mini Quiz: Javascript Scoping

October 8, 2018