top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What will be the answer of below code?

+3 votes
345 views

What will be the answer of below code?

var myObject = {
    foo: "bar",
    func: function() {
        var self = this;
        console.log("outer func:  this.foo = " + this.foo);
        console.log("outer func:  self.foo = " + self.foo);
        (function() {
            console.log("inner func:  this.foo = " + this.foo);
            console.log("inner func:  self.foo = " + self.foo);
        }());
    }
};

myObject.func();

posted Dec 30, 2014 by Merry

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

The output will be:
Creating a JavaScript Object.

answer Jan 2, 2015 by Rahul Singh
...