码迷,mamicode.com
首页 > 编程语言 > 详细

javascript自定义对象的三种方式

时间:2015-10-05 14:20:38      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:

//

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
    people = new Object();
    people.name = "aaronswartz";
    people.age = 26;
    people.sex = "male";
    document.write("name:"+people.name+"<br/>");
    document.write("age:"+people.age+"<br/>");
    document.write("sex:"+people.sex+"<br/>");
</script>
<hr/>
<script type="text/javascript">
lang={name:"javascript",
          age:23
          }
    document.write("name:"+lang.name+"<br/>");
    document.write("age:"+lang.age+"<br/>");
</script>
<hr/>
<script type="text/javascript">
function person(name,height,weigh){
        this._name=name;
        this._height=height;
        this._weigh=weigh;
    }
rose = new person("DerrickRose","4800px","90kg");
            document.write("name:"+rose._name+"<br/>");
            document.write("height:"+rose._height+"<br/>");
            document.write("weigh:"+rose._weigh+"<br/>");
</script>
</body>
</html>


javascript自定义对象的三种方式

标签:

原文地址:http://my.oschina.net/dongdong11019/blog/513585

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!