The folder structure of our enumeration app extends the structure of
the validation app by adding the library files
browserShims.js and
Enumeration.mjs in the lib
folder. Thus, we get the following folder structure with four files in the
lib folder:
publicLibrary
css
lib
browserShims.js
errorTypes.mjs
util.mjs
Enumeration.mjs
src
index.htmlIn the browserShims.js file, we define a few
extensions of the built-in JS object Array, representing a
class, by adding two class-level functions (max and
min), and two instance-level functions (clone
and isEqualTo). These helper functions are used, e.g., in
v/updateBook.mjs.
In the Enumeration.js file, discussed in the
next section, we define a meta-class Enumeration for creating
enumerations as instances of this meta-class with the help of statements
like GenderEL = new Enumeration(["male", "female",
"other"]).