大鸟的学习乐园
路漫漫其修远兮,吾将上下而求索
posts - 26,comments - 27,trackbacks - 0
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

只有注册用户登录后才能发表评论。


网站导航: