实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
    <title>Prototype Chaining Example 3</title>
5
    <script type="text/javascript">
6
                            
7
        function SuperType(){
8
            this.property = true;
9
        }
10
        
11
        SuperType.prototype.getSuperValue = function(){
12
            return this.property;
13
        };
14
        
15
        function SubType(){
16
            this.subproperty = false;
17
        }
18
        
19
        //inherit from SuperType
20
        SubType.prototype = new SuperType();
21
        
22
        //try to add new methods this nullifies the previous line