There are two ways Javascript code used within a HTML application is stored.
1. You can embed the Javascript code within the HTML file itself using one version of a script element, this is basically how the contents of the story's Story Javascript area is handled.
The element would eventually look something like the following:
<script type="text/javascript">
/* Story's Javascript. */
var variable = "value";
</script>
2. You can reference an external JS file using a different version of a script element, and the JS file's contents will be pulled into the HTML document (DOM) after the HTML file is opened.
The element would look something like the following:
<!-- HTML4 and (x)HTML -->
<script type="text/javascript" src="external-file-name.js"></script>
<!-- HTML5 -->
<script src="external-file-name.js"></script>
... the above method assumes that the Javascript contained within the JS file will be used by the HTML file loading (and executing) it and that any visual output (either DOM manipulation or canvas element based) will appear within the HTML document generated by the HTML file.
There are restrictions on what the Javascript can do when it comes to access the resources of the current machine and it's operating system, which is why the above methods generally can't run self-contained Javascript applications that have their own non-HTML based GUI.