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>

浙公网安备 33010602011771号