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

JavaScript面向对象编程笔记

时间:2015-05-09 22:09:54      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html> 
<html>
<head>
    <title>面向对象编程</title>
    <script type="text/javascript">
        var person = {};//或者这样:var person = new Object();
        person.name = "张三";
        person.age = 20;
        //函数充当属性,属性变方法了!
        person.info = function() {
            alert(person.name);
        }
        person.info();
    </script>
    
    <script type="text/javascript">
        var people = {
            name: "李四",
            age: 30,
            info: function() {
                setTimeout("alert(people.name)",3000);
            }
        };
        people.info();
    </script>
    
    <script type="text/javascript">
        function man(name,age) {
            this.姓名 = name;
            this.年龄 = age;
            this.个人信息 = function() {
                alert(this.姓名);
            }
        }
        var m1 = new man("王五", 32);
        m1.个人信息();
    </script>
</head>
<body>

</body>
</html>

JavaScript面向对象编程笔记

标签:

原文地址:http://blog.csdn.net/lucky51222/article/details/45604449

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