It would be exceedingly handy if I could do this:
var MyObject = function(param1, param2, ... paramN)
{
this.var1 = stuff;
this.var2 = moreStuff;
.
.
.
this.varN = nStuff;
this.validate = function()
{
for(var current in this)
{
alert(current);
//validate all member variables (even this function I suppose)
}
};
};
This however does not seem to do what I would want. I realize that the loop would eventually have to loop over it's parent function (which also, not surprisingly, does not happen).
Is this impossible because the 'this' in the second function refers to the second function and not the first? Or is the keyword 'this' only a declaration operator for a public member and not a reference to the outer object ?
I figure getting what I want this way is not possible but is there another way I can go about achieving this behaviour ?