javascript 对象的简单使用

来源:互联网 发布:淘宝小号注册机源码 编辑:程序博客网 时间:2024/05/16 00:48

1. javascript 对象的简单使用 (一)

<script type="text/javascript">Student.prototype={id:null,name:null,sex:null,age:null,show:function (){//类对象的方法,使用属性时必须使用 thisalert("id:" + this.id +",name:" + this.name + ",sex:" + this.sex + ",age:" + this.age);}};function Student(){//构造函数,必须有}//创建对象的方式var student = new Student();student.id = 1001;student.name = "zhangsan";student.sex = "20";student.age = 10;student.show();</script>


 

0 0
原创粉丝点击