12  Factories and Constructors

In the previous chapter, you learned how to import audio files. You also learned that loading multiple files can require a tremendous amount of code duplication. Because repeating code is something that should be avoided, it is a good idea to abstract your audio file loading program into a library that imports all the required files with a minimal amount of code duplication. In this chapter, you will learn two new object creation patterns to help you do this. The first pattern, called factory, is used to create your audio loader library. The second pattern, called constructor, is introduced primarily because of its prevalence in the JavaScript world, making it an important pattern to familiarize yourself with. ...

Get JavaScript for Sound Artists now with O’Reilly online learning.

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