I encountered this example in a beginning Python book that I
have
duplicated in JavaScript. Can someone explain why this
works?
Specifically, how is the parameter "number"
being stored? How are two
parameters being passed?
function multiple(factor) {
function multiplyBy(number) {
return number * factor;
}
return multiplyBy;
}
var double = multiple(2);
alert(double(5));
[this returns 10]
Is it that the previous parameter (2) becomes
"number" and is stored as
part of double? I've done a lot of fairly advanced
scripting but this
simple example has revealed an area I'm completely ignorant
of. Any
light you might shed on this would be greatly appreciated.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "OOP Javascript" group.
To post to this group, send email to OOP-Javascript googlegroups.com
To unsubscribe from this group, send email to
OOP-Javascript-unsubscribe googlegroups.com
For more options, visit this group at http://
groups.google.com/group/OOP-Javascript
-~----------~----~----~----~------~----~------~--~---
|