Abstraction is the process of hiding lower level implementation details so that a developer can concentrate on the bigger picture.
The <script> tag
The <script> tag accepts an optional src attribute to specify an external file to be used for the JavaScript code. To use an external file, it must end with a JS extension.
Header files
You can then go ahead and create a file containing the proper syntax to reference the external script. Further, comments within the header file can be used to expose only the code that is relevant to the script's purpose. Therefore, users of the script will only see a particular method or variable, or whatever.
The result
If you use this approach appropriately, you will find after a while that you have built up a library of useful routines that are trivial to include in other projects.