var bob = new Object();
bob.age = 17;
// this time we have added a method, setAge
bob.setAge = function (newAge){
bob.age = newAge;
bob.getYearOfBirth = function () {
return 2014 - bob.age;

I cann't understand how bob.getYearOfBirth function get bob's age ?


Which lesson is this? A link would be great, thanks.



bob is a defined object with a defined property, age which is bound to the object. bob.age is the value. Note that the variable is bob.age, not just age.