You are looking at documentation for an older release. Not what you want? See the current release documentation.
As your application - typically a portlet - is deployed in pages that contain other applications, it is very important that your JavaScript code is safe from other code, and vice versa, does not harm global variables.
Here are some tips to write your JavaScript code safely:
Follow GMD module patterns as much as possible.
Avoid to write inline scripts if possible. Avoid to include libraries externally (in script tag) if possible.
When using JQuery, use the built-in shared module "jquery" if possible. Use GMD adapter configuration if you need other JQuery versions and extensions.
It is strongly recommended you follow these tutorials:
Adding JavaScript to a portlet - a quick tutorial with code sample.
Developing JavaScript - the complete guideline to module pattern and GMD.