javascript面向对象的写法(代码教程)
<script> //(面向对象的写法 demo) //---构造函数 function createstudentrecord(name,age,telephone){ //添加属性 this.name=name; this.age=age; this.telephone=telephone; } //---添加方法 createstudentrecord.prototype.showname=function (){ alert('我的名字:'+this.name); } createstudentrecord.prototype.showage=function (){ alert('我的年龄:'+this.age); } createstudentrecord.prototype.showtelephone=function (){ alert('我的手机号:'+this.telephone); } //类的实例化 var student_a=new createstudentrecord('tom',28,'13103889999'); //调用类中的方法 student_a.showname(); student_a.showage(); student_a.showtelephone(); //实例化 var student_b=new createstudentrecord('lili',26,'13103669888'); student_b.showname(); </script>
如对本文有疑问, 点击进行留言回复!!
MFC的静态库.lib、动态库.dll(包含引入库.lib)以及Unicode库示例
CTF 刷题记录(一) 白云新闻搜索(手动与自动化SQL注入)
javascript如何使用函数random来实现课堂随机点名方法详解
网友评论