var bob = new Object();
bob.name = "Bob Smith";
bob.age = 20;
// this time we have added a method, setAge
bob.setAge = function (newAge){
bob.age = newAge;
};
// here we set bob's age to 40
bob.setAge(20);
// bob's feeling old. Use our method to set bob's age to 20
No comments:
Post a Comment