1
var jhon = {
                 name : 'Jhon' ,
                 lastName : 'Smith' ,
                 calculateAge : function (){
                                    this.age = 2016 - this.yearOfBirth ;
                                }
            };
  1. console.log(jhon) => "age" propery not in the o/p
  2. jhon.calculateAge(); console.log(jhon);

    ==> "age" property present in the o/p

  3. (This is what confuse me)

    console.log(jhon); jhon.calculateAge(); console.log(jhon);

    ===> "age" property present in both the o/p

Can anyone please explain the reason ?

0 Answers0