function User(properties){
for(var p in properties) {
(function(which){
which["get" + p] = function(){
return properties[p];
};
which["set" + p] = function(val){
properties[p] = val;
};
})(this);
}
}
var user = new User({"name":"tom","age":"444"});
alert(user.name);
alert(user.getname());
user.setage(222);
alert(user.getage());
posted on 2011-05-29 18:37
大鸟 阅读(117)
评论(0) 编辑 收藏 所属分类:
javascript