Part 2. Organizing your programs

Sharing code is common among programmers; many problems have been solved by others already, and your solutions could prove useful in your own future projects, to your team, or to the wider developer community. When code modules are shared, it’s important to make clear how others should use them by defining a clear interface, or set of properties and functions you expect users to utilize. The internals of a module—how you make it do its job—should be protected. Part 2 looks at ways of using local rather than global variables to hide a module’s implementation from other code.

As your programs grow, the need for organization increases, and you’ll start to notice patterns and procedures you use again and ...

Get Get Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.