function User(properties){
for(var i in properties ){ //Traverse all properties of the object and ensure that they work correctly
(function(which){
var p=i;
which["get" p]=function(){ / /Dynamicly generated method
return properties[p]; //Return the property value of the object
};
which["set" p]=function(val){ //Dynamicly generated method
properties[p]=val;
};
})(this); //Self-executing function, this here represents the user object instance
}
}
var user=new User({
name:"Bob",
age:44
});
alert(user.name==null); //Note: the name attribute is not Does not exist because it is a private variable of the attribute object
user.setname("Supersha"); //Call the dynamically generated object and modify the value of the attribute object
alert(user.getname()) ; //Call the dynamically generated object to get the value of the attribute object