Friday 29 March 2013

JavaScript - Predict the Output - Question 5


    var bar = {
       "a": function () {
            alert("Hello");
       }
    };
    
    function foo() {     
         Object.prototype.a = 'Set from prototype';     
         return function inner() {
             alert(bar.a());
          }     
    }

foo()();

1 comment:

  1. alert(bar.a()) execution as follows
    bar.a() executed //output Hello
    alert( return of bar.a() which is Undefined) //output undefined

    ReplyDelete