16. This


// 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;
// and down here we just use the method we already made

I understand the above code, but what the ■■■■ is that line:

bob.setAge = setAge;



bob.setAge = setAge;

that is a redundant statement. I believe that the rest of your code is alright as is.

Is there a specific question you have about this lesson? Otherwise, please refrain from putting profanity in the forums, even if it automatically redacts the response.


Lolman, "bob.setAge = setAge;" is NOT redundant. It is completely necessary for the code to properly execute.
If you didn't have that line, then the function "bob.setAge" would be undefined. By typing "bob.setAge =" you create a method for bob, but it is undefined. So, you point it to the "setAge" function.

Defining setAge and then saying "bob.setAge = setAge;" is the same as saying:

bob.setAge = function (newAge) {
this.age = newAge;

So, no, it's not redundant.


Pyrockstar10844, read my message to lolman. It defines the function "bob.setAge" as the setAge function. It is NOT redundant.


The method must be passed to the new object if you want to use it within the object itself.
You can name the inherited method by the object to whatever you want.
It doesn't have to be the same name as the original method name.

susan.nameItWhatEverYouWant = setAge;


Thanks, now it's a little bit more clear


thanks, it's work for me.