javascript module pattern vs class

Inside shapes.js, we include the following lines: These grab the exports from the individual submodules and effectively make them available from the shapes.js module. However, we've written the path a bit differently — we are using the dot (.) As a side-effect of 2, binds instance.__proto__.constructor to Constructor. How do I correctly clone a JavaScript object? Last but not least, let's make this clear — module features are imported into the scope of a single script — they aren't available in the global scope. I may be misunderstanding what you mean by "Function Object," but these patterns, as I understand them, aren't really interchangeable. We want to export this as our default, so at the bottom of the file we write this: We could instead prepend export default onto the function and define it as an anonymous function, like this: Over in our main.js file, we import the default function using this line: Again, note the lack of curly braces. As modules support special keywords and features, we must tell the browser that a script should be treated as a module, by using the attribute