我试图在下面的代码中调用setAge函数,将bob的年龄改为50 ......但我无法弄清楚如何做到这一点。
// 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
bob.setAge = setAge;
// change bob's age to 50 here using the setAge function