i occured a problem about code below, which i trying to set localproperties with a loop:
function aa(b,c,d){
var args=arguments.callee.toString().match(/function.*\((.*)\)/)[1].split(",");
for(var key=0;key<arguments.callee.length;key++){
this[args[key]]=arguments[key];
}
alert("this.b="+this.b+",this.c="+this.c+",this.d="+this.d);
};
var xxx=new aa(11,22,33);
The thing is: i get the three values correctly in IE,Chrome and Opera; but in Firefox and Safari, i only could get the first(this.b=11,in this case), while the othere two undefined. Does anyone could tell me the reason and how to fix it? thks.
Try
.split(/, */)in line two.Function.prototype.toStringprettyprints in some engines: