Posts

Showing posts with the label module pattern

JavaScript Module Pattern: 2 Forms

JavaScript Module Pattern: 2 Forms The module pattern is a common JavaScript coding pattern. It's generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I'll review the basics and cover some truly remarkable advanced topics, including one which I think is original. In the following guide I will explain two different variation of module pattern that I use during development, namely: Loose Augmentation Function Import Augmentation One limitation of the module pattern so far is that the entire module must be in one file. Anyone who has worked in a large code-base understands the value of splitting among multiple files. Luckily, we have a nice solution to  augment modules . First, we import the module, then we add properties, then we export it. Here's an example, augmenting our  MODULAR  from above: // global object being added to the user space var modular = ( function ...