JavaScript面向对象

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    (function () {
        var n = "me";
        function people(name){
            this.oo=name;
        }
        people.prototype.say= function () {
            alert("poe-hello"+this.oo+n)
        };

        window.people=people;
        return n;
    }());
    (function () {
        function student(name){
            this.oo=name;
        }
        student.prototype=new people();
        var sups=student.prototype.say;
        student.prototype.say= function () {
            sups.call(this);
            alert("stu-hello"+this.oo);

        }
        window.student=student;
    }());

    var s=new student("ii");
    s.say();
</script>
</body>
</html>

 

posted @ 2017-03-18 19:17  张洪源  阅读(110)  评论(0编辑  收藏  举报