实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
AخA
 
1
<script>
2
    function People(name)
3
    {
4
        this.name=name;
5
        //对象方法
6
        this.Introduce=function(){
7
            alert("My name is "+this.name);
8
        }
9
    }
10
    //类方法
11
    People.Run=function(){
12
        alert("I can run");
13
    }
14
    //原型方法
15
    People.prototype.IntroduceChinese=function(){
16
        alert("我的名字是"+this.name);
17
    }
18
    //测试
19
    var p1=new People("Windking");
20
    p1.Introduce();
21
    People.Run();
22
    p1.IntroduceChinese();
23
</script>