Loose augmentation of modules
When we try to enhance a module using the augmentation technique previously discussed, we pass a reference of the module to another part of our code which is responsible for doing the augmentation work.
How can we add functionality to an object that has not been loaded or created yet?
The answer to this question becomes very important when our modules (files) are loaded in an asynchronous fashion, and we have no way of making sure that our original module is loaded before the augmentation code that enhances the module.
One of the beautiful and powerful aspects of JavaScript is its ability to add properties to objects dynamically, at any time during code execution. This allows us to add functionality or modify our original ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access