官术网_书友最值得收藏!

Time for action—determining the value of our options

The following steps help us to determine the value of our options:

  1. Right below where we use the .bark() method on myDog, type in the following code:
    document.write( 'My dog\'s name is ' + myDog.options.name + '.<br />');
    document.write( 'My dog is a ' + myDog.options.type + '.<br />');
    document.write( 'My dog is ' + myDog.options.age + ' years old.<br />');
    
  2. Open up your HTML document on the web browser, and after you exit out of the dialog box that .bark() calls, you should see something like this:
    Time for action—determining the value of our options

Extending classes

Oftentimes, you'll want to extend a class with another class. For example, we might want to extend our Dog class with a class for show dogs that may use the same options, but may do other special things.

We can extend classes with the Extends property. Extends is a property specifically for classes, that not only inherits properties and methods from a parent class, it makes all parent methods available inside a method.

主站蜘蛛池模板: 色达县| 汝城县| 大英县| 安义县| 秀山| 从江县| 张家港市| 新河县| 沂水县| 卓尼县| 河津市| 布拖县| 饶平县| 华亭县| 城口县| 武定县| 肇东市| 蓬莱市| 东山县| 志丹县| 梧州市| 西林县| 区。| 新绛县| 夏邑县| 潞城市| 邹平县| 武定县| 长汀县| 利辛县| 衡山县| 托克逊县| 昭平县| 山阳县| 定陶县| 五大连池市| 墨竹工卡县| 长丰县| 华安县| 武汉市| 阳春市|