Gaining Closure Through Modules
1 2 3 4 5 6 7 8 9 10 11 12 13
party() function has a closure over
timeCapsule(), which means all the variables and functions within timeCapsule remain unmolested by any assignments made outside of their scope.
Modules use closure to encapsulate scope.
1 2 3 4 5
1 2 3 4
Using modules will prevent naming conflicts on functions and variables:
1 2 3 4 5 6 7 8
Voila — no conflicts.