课程: JavaScript Essential Training

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Practice: Build a new method

Practice: Build a new method

- Before we go any further, I want you to practice building methods. Now, as I've already pointed out we haven't covered functions yet so you may feel like you're in deep water here. So let me narrow this practice assignment down for you. In the practice files, there's an object with a bunch a different properties. Some of them are strings, some are numbers, some are Booleans. To practice creating and using methods, I want you to create new methods in this object, one to change each property. The important things to remember here are, one, we pass values to a function by placing them inside the parentheses. Two, from within an object method we refer to the current object as this. Number three, any property can hold any value. So once you can access a property from within a method you can set that property to any value you like.

内容