首页 > 编程语言 > 详细

JavaScript面向对象编程笔记

时间:2015-05-09 22:09:28      阅读:326      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!