What actually the statement want to tell


// here we define our method using "this", before we even introduce bob
var setAge = function (newAge) {
this.age = newAge;
// now we make bob
var bob = new Object();
bob.age = 30;
bob.setAge = setAge; /_/ What does this statement is doing??_

/* I understand the concept of method + function and keyword "this".

So if i need to update any information, i would just call like this


But yes i must be missing some concept of


So please help me in understanding the above code.

Thank You


bob.setAge = setAge

This means that everytime we call setAge from the Bob object it is going to call the function(newAge) since we declared it in the beginning.

The "bob.setAge" can be anything, it can something like this " bob.nowLetMeSetYourAgeForYou = setAge ".

The setAge is a function.