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

javascript - 内置对象

时间:2016-07-15 13:37:17      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:

构建对象的方法

<script>
        //构建对象方法
        //第1种
        var people = new Object();
        people.name = "iwen";
        people.age = 26;
        document.write("name:" + people.name + ",age:" + people.age + "<br>");

        //第2种
        people1 = { name: "zhangsan", age: 27 };
        document.write("name:" + people1.name + ",age:" + people1.age + "<br>");

        //第3种
        function peopleConstructor(name, age) {
            this._name = name;
            this._age = age;
        }
        son = new peopleConstructor("liuz", 28);

        document.write("name:" + son._name + ",age:" + son._age + "<br>");
    </script>
技术分享

javascript - 内置对象

标签:

原文地址:http://www.cnblogs.com/tangge/p/5672907.html

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