JavaScript is a programming language designed to add interactivity to web pages. It was created to allow non-programmers to add dynamic elements and animations to their web designs. JavaScript code is written in scripts that are embedded directly in HTML and can manipulate elements on a web page without reloading. Examples show how JavaScript can be used to preload images and swap images on mouseover and mouseout events to create image rollovers.