Hello There,
I am using the following constructs to parse named arguments:
function whatever() {
if (this.yo) {
if(this.yo=='ma n')
alert('wuzup');
else
alert('nope');
}
if (this.dude) {
if(this.dude==1 )
alert('got one dude');
else
alert('got no-one dude');
}
delete this.dude;
delete this.yo;
}
and I call this function like so:
whatever(dude=2 , yo='woman');
How bad is this kind of usage? Can I expect this to work on
all kinds of javascript implementations ?
I like it because I can use named arguments that can go
in any random order when calling the function.
This currently works on IE 6 and Mozilla Firefox 0.9.
Any comments?
Thanks,
Zac
I am using the following constructs to parse named arguments:
function whatever() {
if (this.yo) {
if(this.yo=='ma n')
alert('wuzup');
else
alert('nope');
}
if (this.dude) {
if(this.dude==1 )
alert('got one dude');
else
alert('got no-one dude');
}
delete this.dude;
delete this.yo;
}
and I call this function like so:
whatever(dude=2 , yo='woman');
How bad is this kind of usage? Can I expect this to work on
all kinds of javascript implementations ?
I like it because I can use named arguments that can go
in any random order when calling the function.
This currently works on IE 6 and Mozilla Firefox 0.9.
Any comments?
Thanks,
Zac
Comment