Idiomatic JavaScript patterns
Every programming language has its own idiomatic patterns. They are design patterns that can be expressed using the specific characteristics and syntax of that programming language.
Our objective is to write good code, which can be tested in the simplest possible way. If we learn how to effectively use JavaScript, we can write clean code and avoid a certain number of additional tests.
There are two idiomatic patterns that are very important in our scenario. We will extensively use them throughout all the My Todo solution:
Constructor functions
Module pattern
Obviously, there are many other patterns and techniques that are extremely useful, for example, Asynchronous Module Definition (AMD) and Dependency Injection (DI), but they are out of the scope of this book in order to keep things simple but ready for further refinements.
Constructor functions
Constructor functions are used to define classes in our solution instead of literals. This is very important, especially...