《悟透javascript》-摘抄2.0

xiaoxiao2021-02-28  76

<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>

转载请注明原文地址: https://www.6miu.com/read-61192.html

最新回复(0)