Object.Method = Method


#1

In the Instruction it is given as

susan.setAge method also equal to setAge

otherwise it is an error .. can anyone explain the meaning of that line of code as below
var setAge = function (newAge) {
this.age = newAge;
};
var susan ={
age : 25
};
susan.setAge = setAge;
susan.setAge(35);

So what is the significance of susan.setAge = setAge; ??


#2

hi, i'm starting too with js. This method can be used from all objects that you like, but for every object, you must explain to use the method.


#3

Significance is that

susan.setAge = setAge;
susan.setAge(35);

will set objectName.setAge equal to setAge variable that we defined is a function.