Skip to content

javascript

JavaScript scope mini-task

What we will see in the console?

var obj = {
    heroName: "Gandalf",
    func: function() {
        var that = this;
        console.log("outer func:  this.heroName = " + this.heroName);
        console.log("outer func:  that.heroName = " + that.heroName);
        (function() {
            console.log("inner func:  this.heroName = " + this.heroName);
            console.log("inner func:  that.heroName = " + that.heroName);
        }());
    }
};
obj.func();

 

The result will be:

Read More →