The "this" Keyword


#1

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

can’t understand about bob.setAge = setAge,
anybody explain plz



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
bob.setAge = setAge;
  
// change bob's age to 50 here
var bob = new Object();
bob.age = 50;
bob.setAge = setAge;



#2

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