The "this" Keyword


#1


https://www.codecademy.com/en/courses/spencer-sandbox/2/4?curriculum_id=506324b3a7dffd00020bf661


No errors; I just have a question about terminology for the following line in this exercise:
bob.setAge = setAge.
My question is, is there a term for what this line is? It's not a function. Is it just a key-value paring? Is there a more technical term to refer to this by?


The whole code is:

// here we define our method using "this", before we even introduce bob
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
bob.setAge = setAge;
  
// change bob's age to 50 here
bob.setAge(50);
console.log(bob.age);


#2

function:

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

then on this line:

bob.setAge = setAge;

we create a method (setAge), but we use an existing function to create the method, rather then creating a new method from scratch

don't think there is a technical term


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.