JavaScript面向对象初步

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
    <!--声明一个函数当成类用-->
        function Account(username, password) {
            this.userName = username;
            this.pwd = password;
            this.sayHello = function () {
                alert('我的账号是:' + this.userName + ' 密码:' + this.pwd);
            }
        }
        var p1 = new Account('luoyqi', 'luoyaqi');
        p1.sayHello();
    </script>

</head>
<body>

</body>
</html>

posted @ 2013-08-04 20:31  第九剑  阅读(96)  评论(0)    收藏  举报