Javascript Folding Pattern
There are many patterns for arranging code in Javascript, such as the Module Pattern, the Revealing Module Pattern and the Prototype Pattern. Most programmers adopt their own style based on these. After creating a project with a lot of interconnected Javascript, I slowly derived this pattern. The Folding Pattern is aware that Javascript is a functional/imperative object-oriented language that employs object prototypes rather than classes. It allows for the concept of private members, which is of importance in large projects (to combat accidental mangling of an object). By sticking to the rigorous formatting you can create very large objects which are easy to maintain and navigate. (Especially if you use an IDE which allows for folding of statement blocks.) Here are two templates (copy them and alter as required) of how to use the Folding Pattern, one is a singleton and the other is a type: //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Folding Pattern - templates //~~~~~~~~~~~~~~~~~~~...