Sunrise
in
Tucson
Flower
of the
Month
Phase
of the
Moon
JavaScript is primarily a client-side development language. Simply put, that means the code runs in your browser on your computer rather than on the website's host server. Fundamentally, it makes your browser do tricks and do them fast. In the olden days, this created some security risks, but modern browsers have locked the doors. Even though it runs on your computer, JavaScript code is denied access to your files. It cannnot see pages from other web sites that you might be surfing. It cannot see your browser history. Today, it's a safe technology that greatly enhances the web experience.
Like the organic development of the Web itself, JavaScript has had a tortuous history. It is only in recent years, as standardization among browsers has improved, that it has come into its own as a reliable tool. Nevertheless, in my opinion, JavaScript should NOT be used for "mission-critical" functions unless a non-JavaScript solution is included as a backup system. Surveys show that a remarkable number of people (estimates vary between 10%-25%) either disable JavaScript or are surfing the web with devices that don't support it, or are working behind firewalls that don't allow it.
AJAX is the hot, new technology that uses JavaScript to open a line of communication between your browser and the server hosting a particular web page. AJAX has made it possible to update parts of a page without reloading the entire page, and is able to give web sites the immediacy of response you normally associate with the software installed on your computer -- like your word processor. Of course, those who disable JavaScript are completely unable to use such a page, and that needs to be taken into consideration.
JavaScript is most frequently used as first-pass form validation, more as a convenience to users than anything else. It can let them know, for example, that they've overlooked a required field or entered an incorrectly formatted value before the form is submitted. It can highlight a field and position the cursor within it. It can also be used to dynamically generate form elements in accordance with choices the user has made in a previous field. For example, if a user chooses hats from a list, a line can magically appear displaying a list of colors of hats to choose from.
Uses for JavaScript are really only limited by one's imagination and the boundaries of security restrictions. It can be used for such silliness as making a train of stars follow the user's cursor or for mouseovers or tooltips or decorating a page or to display animated photo galleries. Please proceed through the demonstrations listed at the left for a few examples.