function User(properties) {
var that = this;
for (var i in properties) {
(function(i){
that["get" + i] = function() {
return properties[i];
}
that["set" + i] = function(val) {
properties[i] = val;
}
})(i);
}
}
var user = new User({
name : "hat_tab",
age : 100500
});
alert(user.getname());
у внутренней функции свой this.