js prototype的使用

来源:互联网 发布:自学java好的课程 编辑:程序博客网 时间:2024/04/24 12:49
<script type="text/javaScript">
function person(name,age,sex){
   this.name=name;
   this.age=age;
   this.sex=sex;
}
 var _persons=new person("张三",20,"男");  //person prototype动态添加属性
  person.prototype.tall=null;
  _persons.tall=180;

  document.write(_persons.name+"--"+_persons.age+"---"+_persons.sex+"--"+_persons.tall);  

</script>


0 0
原创粉丝点击