Quote:
Originally posted by General
let me give you two pieces of code to show you
NPC Code:
//Code 1 - Functions take arguments
function happy(a,b) {
return a*b;
}
variable = happy(2,2);
NPC Code:
//Code 2 - No arguments
fucntion happy() {
this.return=a*b;
}
a=2;
b=2;
happy();
variable=this.return
in both cases variable winds up equaling 4...but notice how much shorter Code 1 is than code 2
|
Well yes, it can be done like that but something like this won't work as good with that:
NPC Code:
function multiplier(var1,var2) {
return var1*var2;
}
blah=1;
blahblah=2;
blahblahblah=3;
this.a=multiplier(blah,blahblah);
this.b=multiplier(blahblah,blahblahblah);