I'm currently working on an app which uses the javascript module pattern (http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html). Can javascript classes be used in combination with this pattern to create a structure like in C#, where classes are nested inside namespaces?
I've currently got this:
app.modules.foo = class {
constructor() {
// Module variables
}
// Module functions
get init() {
// Module initialization function
}
}
Which I would then call like this:
var app = {
modules: {},
init: function () {
"use strict";
this.modules.foo.init();
}
};
window.addEventListener("DOMContentLoaded", function() {
app.init();
});