function User(au_id, name, user_id) {// 创建所有用户的父类,并继承Authority因为每类用户都有自己的权限
this.au_id = au_id;
this.name = name;
this.user_id = user_id;
}
User.prototype = {
compareAnd : function(compareId) {// 判断用户所拥有的权限
return ((this.au_id & compareId) == compareId);
},
getAuId = function() {// 获取权限ID
return this.au_id;
},
getName : function() {// 获取用户名
return this.name;
},
getUserId : function() {// 获取用户ID
return this.user_id;
}
};
function Student(au_id, name, user_id, stu_id) {// Student继承User并增添了自己特有的属性和方法,权限最简单的用户
User.call(this, au_id, name, user_id);
this.stu_id = stu_id;
}
Student.prototype = {
getStuId : function() {
return this.stu_id;
}
}
var stu = new Student(1,"shuang",13,222);
alert(stu.compareAnd(1));
【getAuId = function() {// 获取权限ID
return this.au_id;
}】中的“=”变成“:”即可
this.au_id = au_id;
this.name = name;
this.user_id = user_id;
}
User.prototype = {
compareAnd : function(compareId) {// 判断用户所拥有的权限
return ((this.au_id & compareId) == compareId);
},
getAuId = function() {// 获取权限ID
return this.au_id;
},
getName : function() {// 获取用户名
return this.name;
},
getUserId : function() {// 获取用户ID
return this.user_id;
}
};
function Student(au_id, name, user_id, stu_id) {// Student继承User并增添了自己特有的属性和方法,权限最简单的用户
User.call(this, au_id, name, user_id);
this.stu_id = stu_id;
}
Student.prototype = {
getStuId : function() {
return this.stu_id;
}
}
var stu = new Student(1,"shuang",13,222);
alert(stu.compareAnd(1));
【getAuId = function() {// 获取权限ID
return this.au_id;
}】中的“=”变成“:”即可