The "this" Keyword
Our It turns out we can make a method work for many objects using a new keyword, // 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; Let's look at the method Then when we say Instructions
To show this way of making
Stuck? Get a hint!
Just like in exercise 2, use |
|