The above example shows a general pattern for writing "modules" in javascript, although one that has an error. $ 1 is never called and is private, which means that it cannot exist either. However, in a valid example, additional code will be added that will call $ 1 and, possibly, other functions. Then, when this code has been included, it will all be evaluated, but the global namespace will not be contaminated with declarations.
source share