How can I use JavaScript in a modular way, similar to Java classes?
<p>I'm creating a JavaScript game, previously I've always created the whole game inside a single JavaScript file. I'd like to be able to reduce coupling by separating the code into modules. Is it possible to write JavaScript in one file that is accessible from another file, using some kind of include statement?</p>

<pre><code>&lt;script type="text/javascript" src="assets/scripts/asset_manager.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="assets/scripts/game.js"&gt;&lt;/script&gt;
</code></pre>

<p>I'd like for the javascript files to act in a similar fashion to Javas classes, e.g. within the game.js file writing something like <code>this.extends('asset_manager')</code>.</p>

<p><strong>Edit:</strong>
It looks like RequireJS and CommonJS are both good candidates, have you found any drawbacks or advantages of using either?</p>
