"This" Works for Everyone


#1

getting error ??

// 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;

// make susan here, and first give her an age of 25
var susan={
age:25
};

// here, update Susan's age to 35 using the method
susan.setAge(35);


#2

susan needs the same method assigned as bob had. Then it can be called on that object.


#4

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