《悟透javascript》-摘抄2.0

来源:互联网 发布:淘宝店类目怎么改 编辑:程序博客网 时间:2024/05/17 07:52
<script>    function Person(name){        this.name=name;    };    Person.prototype.company="Microsoft";//原型的属性    Person.prototype.SayHello=function(){        alert("hello,I'm "+ this.name+ " of "+ this.company)    };    var BillGates=new Person("Bill Gates");    BillGates.SayHello();    var SteveJobs=new Person("Steve Jobs");    SteveJobs.company="apple";    SteveJobs.SayHello();    BillGates.SayHello();</script>

这里写图片描述

原创粉丝点击